[英]posting message on facebook wall
我在Facebook上创建了一个应用程序。 现在,我想在Facebook墙上发布消息。由于我是该应用程序的开发人员,因此当我登录到我的Facebook帐户时,该消息就会出现在我的墙上,但是当我登录到另一个用户时,此应用程序却无法获取,并且页面正在重定向到http://www.facebook.com/4oh4.php 。 我的代码如下
$facebook = new Facebook(array(
'appId' => myAppId,
'secret' => myAppSecret,
'cookie' => true,
'req_perms' => 'email,read_stream,read_friendlists,publish_stream,offline_access,manage_pages'
));
$user = $facebook->getUser();
$app_id = myAppId;
$canvas_page = "https://apps.facebook.com/apptestingas/";
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page)."&scope=email,read_stream,read_friendlists,publish_stream,offline_access,manage_pages";
if(isset($_REQUEST["signed_request"]))
{
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
}
if (empty($data["user_id"]))
{
echo("<script> top.location.href='" . $auth_url . "'</script>");
}
else
{
$uid = $data["user_id"];
}
try {
// Proceed knowing you have a logged in user who's authenticated.
echo $token = $facebook->getAccessToken();
$user_profile = $facebook->api('/'.$uid.'',array (
'access_token' => $token)
);
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
if (!empty($user_profile )) {
# User info ok? Let's print it (Here we will be adding the login and registering routines)
echo $username = $user_profile['name'];
$uid = $user_profile['id'];
$facebook->api('/'.$uid.'/feed', 'post', array(
'message' => "sdsgdg testingbbbb",
));
}
请任何人帮忙
您的应用程序是否设置为“沙盒模式”? 这可以在应用设置中控制。 引用描述:“如果启用,则只有应用程序开发人员才能使用应用程序”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.