douxian8883 2012-04-28 12:07
浏览 39
已采纳

如何使用php sdk发布到OpenGraph

I would like to post to my user's wall using php sdk and the new Open Graph is there a way or I shall stick to the typical 'feed' method?

  • 写回答

1条回答 默认 最新

  • doujiao3016 2012-04-28 14:50
    关注

    You can use the following code to post actions on timeline using open graph actions and objects.

    <?php
    require "src/facebook.php";
    
    $facebook = new Facebook(array(
        'appId'=>'xxxxxxxxx',
        'secret'=>'xxxxxxxxxxxxxxxxx',
        'cookie'=>true
    ));
    
    if(!$facebook->getUser())
    {
        $url = $facebook->getLoginUrl(array('scope'=>'publish_actions'));
        echo "<script> top.location=\"".$url."\"; </script>";
        exit(0);
    }
    
    $params = array('article'=>'http://www.onlytipsandtricks.com.com/test.html','access_token'=>$facebook->getAccessToken());
    
    $out = $facebook->api('/me/app_namespace:read','post',$params);
    
    print_r($out);
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?