donkey199024 2012-08-14 12:41
浏览 116
已采纳

使用图API更新Facebook事件

I'm trying to update an existing Facebook event, created by my application. I'm using the PHP SDK to create the event, here is the code for creating the event:

$access_token = $facebook->getAccessToken();
$page_id = $_SESSION['FAN_PAGE_ID'];

// Now, getting the PAGE Access token, using the user access token

$page_token_url = "https://graph.facebook.com/$page_id?fields=access_token&" . $access_token;
$response = file_get_contents($page_token_url);

// Parse the return value and get the Page access token
$resp_obj = json_decode($response,true);

$page_access_token = $resp_obj['access_token'];

$event_param = array(
    "access_token" =>$page_access_token,
    "name" => $postEventName,
    "start_time" => $postEventDate,
    "page_id" => $postFanPageID,
    "description" => $eventDescription,
    "location" => $location
);

try
{
   $fb_event_id = $facebook->api("/$postFanPageID/events", "POST", $event_param);
}
catch (FacebookApiException $e)
{
   echo $e->getMessage();
}

This is successfully creating an event. But I haven't found any documentation about updating an event.

I've tried using the same call but providing my existing eventID:

$facebook->api("/$postFanPageID/events/$facebookEventID", "POST", $event_param);

that just created a new event.

I've tried using this (similar to the code of deleting an event):

$facebook->api($facebookEventID, 'UPDATE', $event_param);

But this returned: Unsupported method by Facebook.

How can I update an event ? thanks.

  • 写回答

1条回答 默认 最新

  • doufei7516 2012-08-14 12:55
    关注

    To edit an event you have to post against the event id only – so not /$postFanPageID/events/$facebookEventID, but just /$facebookEventID instead.

    See https://developers.facebook.com/docs/reference/api/user/#events, https://developers.facebook.com/docs/reference/api/page/#events

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题