0

我在下面有一个 php 脚本,用于将照片上传到 facebook 封面

<?php
if(is_single()){
if($_REQUEST['state']){
$imgsource = show_src('851','315');
}else{
$imgsource = $_POST['o'];
}
if($imgsource){
require_once "script/facebook.php";
$config = array(
'appId' => get_theme_option('app_id'),
'secret' => get_theme_option('secret'),
'fileUpload' => true,
);

$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$photo = str_replace(home_url( '/' ),'',$imgsource);
$message = get_theme_option('descover');
if($user_id) {
try {
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'source' => '@' . $photo,
'message' => $message,
)
);
$hasil3 = '<div id="modal-from-dom" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close">&times;</a>
<h2>You\'re almost done!</h2>
</div>
<div class="modal-body">
<img src="'.get_bloginfo("template_directory").'/images/eee.jpg" />
</div>
<div class="modal-footer">
<a href="http://www.facebook.com/profile.php?id=%27.%24user_id.%27%3Fpreview_cover%3D' . $ret_obj['id'] . '" class="btn primary" target="_blank">Go to Facebook Profile</a>
</div>
</div>
<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true" class="btn large success btnsingle">Preview Timeline</button>';
} catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl( array(
'scope' => 'photo_upload'
));
error_log($e->getType());
error_log($e->getMessage());
}
} else {
$login_url = $facebook->getLoginUrl( array( 'scope' => 'photo_upload') );
if($imgsource){header('Location: '.$login_url);}
}
}
}
?>

它现在不工作,因为 API 中的 photo_upload 权限已弃用,如何修复这个 PHP 脚本工作?

我已经尝试用这些更改 photo_upload,但看起来仍然不对:

publish_stream
publish_actions
user_photos
4

0 回答 0