我正在使用php facebook api 4.0 。我正在使用下面的代码在我的时间轴上发布照片。
FacebookSession::setDefaultApplication($app_id, $app_sc);
$helper = new FacebookRedirectLoginHelper($url_page);
$loginUrl = $helper->getLoginUrl();
$session = new FacebookSession($access_token);
FacebookSession::enableAppSecretProof(false);
if($session) {
try {
$response = (new FacebookRequest(
$session, 'POST', '/me/photos', array(
'source' => '@' . realpath('1.jpg'),
'message' => 'message'
)
))->execute()->getGraphObject();
// If you're not using PHP 5.5 or later, change the file reference to:
// 'source' => '@/path/to/file.name'
echo "Posted with id: " . $response->getProperty('id');
} catch(FacebookRequestException $e) {
echo "Exception occured, code: " . $e->getCode();
echo " with message: " . $e->getMessage();
}
}
但我收到Exception occured, code: 324 with message: (#324) Requires upload file
错误。我认为有一点是, fileupload support 应设置为on。但我不知道从哪里开启它。