Howto use FB Graph to post a message on a feed (wall)

前端 未结 7 1693
谎友^
谎友^ 2020-12-23 12:50

I have created an app, and now i want to post a message on one of my friends wall with use of the new Graph API. Is this do-able?

I am already using oAuth and the Gr

相关标签:
7条回答
  • 2020-12-23 13:28

    As the link says: enter link description here

    <?php 
      $app_id = "YOUR_APP_ID";
      $app_secret = "YOUR_APP_SECRET";
      $my_url = "YOUR_POST_LOGIN_URL"; 
      $code = $_REQUEST["code"];
      if(empty($code)) {
        $dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
        . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;scope=email";
        echo("<script>top.location.href='" . $dialog_url . "'</script>");
      }
      $token_url = "https://graph.facebook.com/oauth/access_token?client_id="
        . $app_id . "&amp;redirect_uri=" . urlencode($my_url)
        . "&amp;client_secret=" . $app_secret
        . "&amp;code=" . $code;
      $access_token = file_get_contents($token_url);
      $graph_url="https://graph.facebook.com/me/permissions?".$access_token;
      echo "graph_url=" . $graph_url . "<br />";
      $user_permissions = json_decode(file_get_contents($graph_url));
      print_r($user_permissions);
    ?>
    
    0 讨论(0)
提交回复
热议问题