本文整理汇总了PHP中Publication::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Publication::setBody方法的具体用法?PHP Publication::setBody怎么用?PHP Publication::setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publication
的用法示例。
在下文中一共展示了Publication::setBody方法的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,
// ) );
}