0
我想使用curl將圖片上傳到Google Picasa,我發現這一行代碼使用curl將圖片上傳到Google Picasa但我不知道如何將其轉換爲php和捲曲以便能夠使用它。如何在php curl中編寫此代碼
curl --silent --request POST --data-binary "@sweeping_the_rock.png" --header "Slug: Sweeping the rock" --header "Content-Type: image/png" --header "Authorization: GoogleLogin auth=ABCDEFG" "http://picasaweb.google.com/data/feed/api/user/brad.gushue/albumid/5113621341847124417" | tidy -xml -indent -quiet
$file = "C:/Users/Michael/Desktop/182178_271150652992340_118089494_n.jpg";
$postimg = "https://picasaweb.google.com/data/feed/api/user/userId/albumid/albumId";
$header = array("Content-Type: image/jpeg",
"Content-Length: ".filesize($file),
"Authorization: GoogleLogin auth=$token",
"Slug: 182178_271150652992340_118089494_n.jpg"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postimg);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($file));
$hasil = curl_exec($ch);
curl_close($ch);
來源:https://developers.google.com/gdata/articles/using_cURL#media-support
你好,歡迎來到StackOverflow。儘管您的計劃可能會遇到麻煩,但我們強烈建議(並堅持)在向社區尋求幫助之前,您已盡其最大努力。很明顯,您遇到了您嘗試過的代碼問題,我們很樂意提供幫助!如果您沒有花費精力設計自己的解決方案,我們傾向於對您的問題進行降級投票並關閉它。你必須至少嘗試一個解決方案。絕不要求別人寫代碼來代替誠實的努力。總之,[你試過什麼](http://www.whathaveyoutried.com)? – Matt
[PHP Curl文檔](http://www.php.net/manual/en/ref.curl.php)應該是有用的。 –
那麼你在哪裏遇到問題?你捲曲錯誤?你沒有得到你期望從API中得到的迴應嗎? –