当前位置: 首页>>代码示例>>PHP>>正文


PHP Facebook::post方法代码示例

本文整理汇总了PHP中Facebook::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Facebook::post方法的具体用法?PHP Facebook::post怎么用?PHP Facebook::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook的用法示例。


在下文中一共展示了Facebook::post方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __call

 /**
  * Handle postTo* methods.
  *
  * @param string $method
  * @param array $arguments
  */
 function __call($method, $arguments)
 {
     if (text($method)->startsWith('get')) {
         // a get*($parameters) method?
         if (empty($this->id)) {
             throw new \Exception('Can\'t fetch a connection without an id');
         }
         if (count($arguments) > 0) {
             $parameters = $arguments[0];
         } else {
             $parameters = array();
         }
         $connection = lcfirst(substr($method, 3));
         $connections = $this->getKnownConnections(array('id' => $this->id));
         if (isset($connections[$connection]['class'])) {
             $class = $connections[$connection]['class'];
         } else {
             $class = '\\Sledgehammer\\GraphObject';
         }
         if (isset($connections[$connection]['permission']) && $connections[$connection]['permission'] !== 'denied' && in_array($connections[$connection]['permission'], Facebook::getInstance()->getPermissions()) === false) {
             notice('Connection "' . $connection . '" requires the "' . $connections[$connection]['permission'] . '" permission', 'Current permissions: ' . quoted_human_implode(' and ', Facebook::getInstance()->getPermissions()));
         }
         $objects = array();
         $response = Facebook::all($this->id . '/' . $connection, $parameters);
         foreach ($response as $data) {
             $objects[] = new $class($data);
         }
         if (empty($arguments['fields'])) {
             foreach ($objects as $object) {
                 $object->_state = 'partial';
             }
         }
         return new Collection($objects);
     }
     if (text($method)->startsWith('postTo')) {
         // a postTo*($data) method?
         if (empty($this->id)) {
             throw new \Exception('Can\'t post to a connection without an id');
         }
         if (count($arguments) > 0) {
             $parameters = $arguments[0];
         } else {
             notice('Missing argument 1 for ' . $method . '()');
             $parameters = array();
         }
         $response = Facebook::post($this->id . '/' . lcfirst(substr($method, 6)), $parameters);
         return new GraphObject($response['id']);
     } else {
         return parent::__call($method, $arguments);
     }
 }
开发者ID:sledgehammer,项目名称:facebook,代码行数:57,代码来源:GraphObject.php

示例2: postToFacebook

 protected function postToFacebook($confession, $user = null)
 {
     if (env('MANUAL_MODE', false)) {
         return 0;
     }
     if ($confession->images) {
         if ($confession->fb_post_id) {
             $endpoint = '/' . $confession->fb_post_id;
         } else {
             $endpoint = '/' . env('FACEBOOK_PAGE_ID', '') . '/photos';
         }
         $response = \Facebook::post($endpoint, ['message' => $confession->getFacebookMessage(), 'url' => $confession->images], $this->getPageToken($user))->getGraphObject();
         if ($confession->fb_post_id) {
             return $confession->fb_post_id;
         } else {
             return $response['id'];
         }
     } else {
         if ($confession->fb_post_id) {
             $endpoint = '/' . env('FACEBOOK_PAGE_ID', '') . '_' . $confession->fb_post_id;
         } else {
             $endpoint = '/' . env('FACEBOOK_PAGE_ID', '') . '/feed';
         }
         $response = \Facebook::post($endpoint, ['message' => $confession->getFacebookMessage()], $this->getPageToken($user))->getGraphObject();
         if ($confession->fb_post_id) {
             return $confession->fb_post_id;
         } else {
             return explode('_', $response['id'])[1];
         }
     }
 }
开发者ID:nekonekonik,项目名称:nuswhispers,代码行数:31,代码来源:ConfessionsRepository.php


注:本文中的Facebook::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。