私のコード(動作しない):はどのアルバムに写真をアップロードするには、グラフAPIを使用する
<?php
require '../src/facebook.php';
$facebook = new Facebook(array(
'appId' => '...',
'secret' => '...'
));
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$album_id = '246592692052269';
$FILE_PATH = 'Language.jpg';
$access_token = $_SESSION['fb_appId_access_token'];
$logoutUrl = $facebook->getLogoutUrl();
$args = array('image'=> '@' . __DIR__.$FILE_PATH,
'name' => 'this photo was taken in acre',
'message'=> 'Photo Caption');
$ch = curl_init();
$url = 'http://graph.facebook.com/'.$album_id.'/photos?access_token='.$access_token;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
//returns the photo id
if(empty($data)) {
echo 'Responde: '. $data . '<pre>';
print_r(curl_getinfo($ch));
echo '</pre>';
} else {
echo 'Upload failed! erro='. curl_error($ch);
}
} else {
$loginUrl = $facebook->getLoginUrl();
}
?>
が出力:
Array
(
[url] => http://graph.facebook.com/246592692052269/photos?access_token=...
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.203
[namelookup_time] => 0
[connect_time] => 0.203
[pretransfer_time] => 0.203
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
)
誰かが私の誤りを指摘することはできますか?前もって感謝します。