doulu1020 2013-10-08 23:28
浏览 33
已采纳

如何在发布后返回Facebook事件ID,以便我可以添加封面照片?

I am using the following code (found on SO) to post Events on behalf of my Facebook page.

require_once 'fb-sdk/facebook.php';

$facebook = new Facebook(array(
    'appId' => 'APPID',
    'secret' => 'SECRET'
));

$facebook->setAccessToken('TOKEN');

try {
    $retObj = $facebook->api('/PAGE_ID/events/create', 'POST', array(
        "name" => 'Test Event 1234',
        "description" => 'This is a test!!',
        "start_time" => '2013-03-19'
    ));

} catch(FacebookApiException $e) {
    echo $e->getMessage();
}

This works fine and dandy to create the event, but then afterwards I want to come back and add a Cover Photo to the event using the following code (again, found on SO):

$cover['cover_url']     = 'MYIMAGE.jpg';
$eventUpdate = $facebook->api( "/" . $fbEvent['id'], 'post', $cover );

This code requires an event ID that is generated when the event is posted.. so my question is:
how do I return the Event ID after posting an event, so it can be used to update my Event Cover Photo?

Or better yet, is there a streamlined way of creating the event, and adding the Cover Photo all in one go?

  • 写回答

1条回答 默认 最新

  • doubengshao8872 2013-10-08 23:57
    关注

    you just want to get event id you created ?

    add this code at the end of your first code $id=$retObj['id']; OR $id=$retObj[0]['id']; not sure which one but i think first one should work

    you can find helpful information by adding this code at the end of first code echo '<pre>'; print_r($retObj); echo '</pre>';

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

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境