ここでは、このスクリプトをFacebookアプリに使用しています。
ユーザーのFacebookプロファイルに写真をアップロードし、その写真の新しいアルバムを作成します。
スクリプトは、アルバム名/タイトル(引用符なし)として「 [APPNAME] Photos 」を返します。
- [APPNAME]は私のFacebookAPPの名前です-
基本的に、そのアルバムのタイトルは必要ありません。スクリプトでアルバムタイトルを指定したい。
私が欲しいのは:
- ...スクリプトから作成するアルバムの名前/タイトルを指定できるようにします。
- また、可能であれば、アルバムの説明も指定してください。
これはスクリプトです-
$root_url = "http://www.WEBSITE.COM/";
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
// Get image from URL
$img = $_GET['i'];
// Change location depending on which type of cover
if($get_set != 1) {
$photo = './PATH/'.$img.''; // Path to the photo on the local filesystem
} else {
$photo = './PATH/'.$img.'';
}
$message = 'THIS IS THE PHOTO CAPTION';
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>';
print "<script>window.location = '".$root_url."index.php?cover=uploaded'</script>";
} 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 '<script> window.location = "' . $login_url . '"; </script>';
error_log($e->getType());
error_log($e->getMessage());
}
echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} 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 '<script> window.location = "' . $login_url . '"; </script>';
//echo 'Please <a href="' . $login_url . '">login</a> to continue.';
}
ここでこれを見て、私はそれが可能であると確信しています。
$album_name = 'YOUR_ALBUM_NAME';
$album_description = 'YOUR_ALBUM_DESCRIPTION';
私はそこでそれをどのように機能させるかを知りません...
解決策を楽しみにしています。御時間ありがとうございます!