我想使用 curl 将图片上传到 Google picasa,我发现这行代码使用 curl 将图片上传到 Google picasa 但我不知道如何将其转换为 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