douchun5976 2015-09-14 04:34
浏览 81
已采纳

获取Facebook Graph API扩展访问令牌

I can get the posts I need from a Facebook Page using this code in PHP:

$token = "ACCESS_TOKEN";
$data = file_get_contents("https://graph.facebook.com/PAGE_ID/feed?access_token=".$token);
$data = json_decode($data, true);

However, the access token it just last 1 hour. I saw that it's possible to request a long live token that lasts 60 days, but stills not so clear for me with a good example.

Do you guys know a good example using PHP? Thank you in advance!

  • 写回答

2条回答 默认 最新

  • doudou8783 2015-09-14 04:52
    关注

    As per the Facebook documentation, you need to pass the short-lived access-token with app secret and in return you will get the Long-lived access-token

    To get the long-lived user access_token simply pass your own client_id (your app_id), your app_secret, and the non-expired, short-lived access_token to the endpoint below. You will be returned a new long-lived user access_token; this access_token will exist in addition to the short-lived access_token that was passed into the endpoint.

    Code Sample

    https://graph.facebook.com/oauth/access_token?             
        client_id=APP_ID&
        client_secret=APP_SECRET&
        grant_type=fb_exchange_token&
        fb_exchange_token=EXISTING_ACCESS_TOKEN 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站