您好这是我的测试代码,以便发布到Facebook墙。如果SOME_USER是我的工作,如果它是另一个用户,它不会!有人可以解释什么是错的吗?谢谢!!
我的应用程序处于沙箱模式,但我也尝试过,没有任何改变!
<?php
require_once 'src/facebook.php';
$msg = 'Some message would go here.';
$title = 'Some title would go here';
$uri = 'http://test.com';
$desc = 'Some detailed message.';
$action_name = 'Action Link in the Footer of the Post';
$action_link = 'http://www.test.com';
$scope = "publish_stream,publish_actions";
$app_id = "xxx";
$app_secret = "xxxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook->getUser();
if ($user) {
try {
$accessToken = $facebook->getAccessToken();
if (!empty( $accessToken )) {
$attachment = array(
'access_token' => $accessToken,
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link,'scope' => $scope))
);
$status = $facebook->api("/SOME_USER/feed", "post", $attachment);
}
} catch (FacebookApiException $e) {
$user = null;
}
}else {
header("Location:{$facebook->getLoginUrl(array('scope' => 'publish_stream,publish_actions'))}");
}