當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Publication::setObjectId方法代碼示例

本文整理匯總了PHP中Publication::setObjectId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Publication::setObjectId方法的具體用法?PHP Publication::setObjectId怎麽用?PHP Publication::setObjectId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Publication的用法示例。


在下文中一共展示了Publication::setObjectId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createEvent

 /**
  * Creates an event on Facebook.
  *
  * @param string $title Title of the event.
  * @param int $start Epoch timestamp for the event start.
  * @param int $end Epoch timestamp for the event end.
  * @param string $location Location of the event.
  * @param string $description Description of the event.
  * @param string $picture Local path (no URL) of the picture for the event.
  *
  * @return array Result set of the Facebook API call.
  * @todo Standardise the result sets of connection API calls.
  */
 public function createEvent($objectId, $title, $start, $end, $location, $description, $picture = null)
 {
     // Privacy types: OPEN, CLOSED, SECRET
     $start = is_numeric($start) ? date("c", $start) : $start;
     $end = is_numeric($end) ? date("c", $end) : $end;
     $attachment = array("privacy_type" => "OPEN", "name" => $title, "host" => "Me", "start_time" => $start, "end_time" => $end, "location" => $location, "description" => $description);
     if ($picture) {
         $attachment[basename($picture)] = "@" . realpath($picture);
         $this->api()->setFileUploadSupport(true);
     }
     try {
         // TODO: support pages (page Id instead of "me")
         $rs = $this->api()->api('me/events', 'post', $attachment);
     } catch (Exception $e) {
         Log::error("Exception: {$e}");
     } catch (FacebookApiException $e) {
         Log::debug("FacebookApiException {$e}, " . print_r($attachment, true) . print_r($this, true));
         return null;
     }
     $publication = new Publication();
     $publication->setObjectId($objectId);
     $publication->setConnectionId($this->externalId);
     $publication->setBody(serialize($attachment));
     $publication->setResponse(serialize($rs));
     if (isset($rs['id'])) {
         list($uid, $postId) = explode("_", $rs['id']);
         $publication->setExternalId($postId);
     } else {
         $result->error = $rs;
         Log::debug("error: {$result->error}");
     }
     $publication->save();
     return $rs;
     // TODO: invites
     // $fb->api( array(
     //   'method' => 'events.invite',
     //   'eid' => $event_id,
     //   'uids' => $id_array,
     //   'personal_message' => $message,
     // ) );
 }
開發者ID:robkaper,項目名稱:kiki,代碼行數:54,代碼來源:facebook.php


注:本文中的Publication::setObjectId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。