【问题标题】:Using OpenGraph with PHP (cUrl requests for actions)将 OpenGraph 与 PHP 一起使用(cUrl 操作请求)
【发布时间】:2011-12-02 22:32:40
【问题描述】:

我为我的网站创建了一个应用程序,设置了操作(阅读)和对象(文章),并将对象代码(头部的 META 标记)放置在我网站的文章页面中。

现在,我想知道如何在用户阅读我网站上的文章时发送 cUrl 请求,以便将其放在他的墙上。

当我按下操作附近的“获取代码”链接时,这就是我得到的:

curl -F 'access_token=***' \
 -F 'article=http://example.com' \
    'https://graph.facebook.com/me/yellowheart:read'

(当然有一个实际的访问令牌)。

现在,我该如何实现呢?

丹尼尔。

【问题讨论】:

    标签: php facebook facebook-opengraph


    【解决方案1】:
    $facebook->api('/me/'.FB_NAME_SPACE.':action','POST',
       array('facility'=>'http://www.mysite.com/object?id=1')
                                 );
    

    https://developers.facebook.com/docs/reference/php/facebook-api/

    【讨论】:

      【解决方案2】:

      使用 PHP SDK,您将使用 api 方法。

      $config = array();
      $config['appId'] = 'YOUR_APP_ID';
      $config['secret'] = 'YOUR_APP_SECRET';
      
      $facebook = new Facebook($config);
      ...
      $facebook->api('https://graph.facebook.com/me/yellowheart:read?  
                      article=http://example.com'','POST');
      

      你也可以做一个原始请求

      $myurl = 'https://graph.facebook.com/me/yellowheart:read? 
                article=http://example.com&access_token=ACCESS_TOKEN&method=post';
      
      $result = file_get_contents($myurl);
      

      【讨论】:

      • 你在哪里设置access_token?
      • @Zorayr - 我已经编辑以明确显示 api 案例中的配置变量和原始请求中的参数
      【解决方案3】:

      我关注了the tutorial“食谱盒”,并逐步了解了如何“让它发生”。希望在某种程度上有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-18
        • 1970-01-01
        • 2019-12-20
        • 2019-12-26
        • 1970-01-01
        • 2019-04-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多