-2

我想创建一个使用 Facebook Auto post 的网站。

当用户点击视频或文章时,他将被重定向到 Facebook 应用登录页面。然后当他与 Facebook 连接时,该网站将在用户的墙上发布。

我按照以下说明操作:https ://developers.facebook.com/docs/howtos/login/server-side-login/

我的代码如下所示:

$app_id = "xxxxx";
$app_secret = "xxxx";
$my_url = "http://xxxx.com/";

session_start();

$code = $_REQUEST["code"];

if(empty($code)) {
    $_SESSION['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection
    $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
        . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
        . $_SESSION['state'] . "&scope=publish_actions";

   echo("<script> top.location.href='" . $dialog_url . "'</script>");
}

如何嵌入自动邮政编码?

4

1 回答 1

0

这应该可以正常工作:

$attachment = array(
   'message' => "Your post message goes here",
   'access_token' => $accessToken // the obtained access token with publish_stream permission
);

$result = $facebook->api('/me/feed/', 'post', $attachment);

var_dump($result); // echo the post_id
于 2012-11-26T06:01:26.870 回答