Php Facebook照片发布应用程序没有';不行?
我使用了一个名为“上传照片到用户档案”的Facebook开发者脚本(请查看:),但它不起作用 这是我的密码:Php Facebook照片发布应用程序没有';不行?,php,facebook,photo,Php,Facebook,Photo,我使用了一个名为“上传照片到用户档案”的Facebook开发者脚本(请查看:),但它不起作用 这是我的密码: <?php // Remember to copy files from the SDK's src/ directory to a // directory in your application on the server, such as php-sdk/ require_once('facebook/src/facebook.php'); $config
<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('facebook/src/facebook.php');
$config = array(
'appId' => 'I_ENTERED_MY_APP_ID_HERE',
'secret' => 'I_ENTERED_MY_APP_SECRET_HERE',
'fileUpload' => true,
'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$photo = '/pictures/1.jpg'; // Path to the photo on the local filesystem
$message = 'Look at this picture I just uploaded !';
?>
<html>
<head></head>
<body>
<?php
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
// Upload to a user's profile. The photo will be in the
// first album in the profile. You can also upload to
// a specific album by using /ALBUM_ID as the path
$ret_obj = $facebook->api('/me/photos/', 'POST', array(
'source' => '@' . $photo,
'message' => $message,
)
);
echo '<pre>Photo ID: ' . $ret_obj['id'] . '</pre>';
echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl( array(
'scope' => 'photo_upload'
));
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
// To upload a photo to a user's wall, we need photo_upload permission
// We'll use the current URL as the redirect_uri, so we don't
// need to specify it here.
$login_url = $facebook->getLoginUrl( array( 'scope' => 'photo_upload') );
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
当我刷新我的网页时,它不会将数据库中的图像上传到我的墙上。。。有人能告诉我出了什么问题吗?有错误吗<代码>错误日志($e->getMessage())代码>将记录错误!谢谢你的回答。它告诉我:
致命错误:在第63行的/home/u629000819/public_html/default.php中对非对象调用成员函数getMessage()