【问题标题】:Can I automatically publish facebook posts on a website from my facebook profile?我可以从我的 Facebook 个人资料自动在网站上发布 Facebook 帖子吗?
【发布时间】:2014-09-02 19:10:05
【问题描述】:

我正在尝试在我的网站页面上显示我的 facbook 个人资料的所有帖子。我可以得到这个。是否可以从网站上的 facebook 获取帖子。

如果可以的话,请告诉我解决方案。

我已经阅读了here 的问题,而不是这个。

我正在使用这个$token = 'https://graph.facebook.com/oauth/access_token?client_id='.APP_ID.'&client_secret='.APP_SECRET.'&grant_type=client_credentials';

获取访问令牌但显示错误消息{ "error": { "message": "Error validating application. Invalid application ID.", "type": "OAuthException", "code": 101 } }

我正在使用正确的 APP_ID 和 APP_SECRET.. 但无法获取访问令牌..

谁能告诉我如何获得上述问题所需的访问令牌。

【问题讨论】:

    标签: php facebook facebook-graph-api


    【解决方案1】:

    您需要长期有效的访问令牌。

    有一种方法可以将其延长至 60 天。这里描述: https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal/

    为了扩展访问令牌,您需要使用短期访问令牌发出以下请求:

    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 
    

    以及如何使用此脚本在墙上发帖

    $page_access_token = 'your access token';
    $page_id = 'page id';
    $data['message'] = "";
    $data['access_token'] = <Your access token>;
    $post_url = 'https://graph.facebook.com/'.$page_id.'/feed';
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $post_url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $return = curl_exec($ch);
    curl_close($ch);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多