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中得到的回应吗? –