我想用PHP向我的Facebook好友发送消息。我找到了一些代码,但它只是让我登录。有人可以帮助我吗?
<?php
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXXXX',
'secret' => 'XXXXX',
'cookie' => true,
));
$session=$facebook->getUser();;
if ($session) {
$logoutUrl = $facebook->getLogoutUrl();
$access_token = $facebook->getAccessToken();
try {
$result = $facebook->api(
'me/feed',
'post',
array('access_token' => $access_token , 'message' => 'test')
);
} catch (FacebookApiException $e) {
error_log($e);
}
}
答案 0 :(得分:0)
1)您是否为应用提供了正确的权限?
$login_url = $facebook->getLoginUrl( array(
'scope' => 'publish_stream'
));
2)检查此答案:Update facebook status using php和此:Facebook PHP SDK , Post to another users wall whats wrong?
3)这是/我/饲料,而不是我/饲料:
$result = $facebook->api(
'/me/feed',
'post',
array('access_token' => $access_token , 'message' => 'test')
);