【发布时间】:2010-01-19 11:14:15
【问题描述】:
我需要一些帮助来解决这个问题,拜托。 这几天我一直在尝试。
检索提要并解析它们并不是真正的问题,但是 以关闭xml的形式上传数据是什么?
下面的代码也部分来自谷歌文档示例代码,但显然它不起作用。
我希望其他人更深入地研究 google api 工作,因为我不知道。 目前,我只是尝试为相册中的照片添加标签。 一旦成功了,我可能也可以完成其余的工作。
public function postTag() {
$query='smarty';
$this->updateOptie('tag', $query);
$feedUrl = $this->creeerFeedUrl('myalbum', false);
$picasa = $this->parseFeed( $feedUrl );
$gphoto = $picasa['gphoto'][0];
$gphotoid = $gphoto['id'];
//return $gphotoid;
////////////////////sofar no problem//////////////////
$tag = "mytag";
$data = "<entry xmlns='http://www.w3.org/2005/Atom'>
<title>$tag</title>
<category scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/photos/2007#tag\"/>
</entry>";
$albumid = 'myalbum';
$itemsFeedURL = $this->krijgPicasaBasisUrl(). "/albumid/$albumid/photoid/$gphotoid";
$len=strlen($data);
$headers = array(
"Authorization: GoogleLogin auth=" . $this->auth,
"GData-Version: 2",
'Content-Type: application/atom+xml',
"Content-Length: $len",
);
$ch = curl_init(); /* Create a CURL handle. */
/* Set cURL options. */
curl_setopt($ch, CURLOPT_URL, $itemsFeedURL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$result = curl_exec($ch); /* Execute the HTTP request. */
$info = curl_getinfo($ch);
curl_close($ch); /* Close the cURL handle. */
return $info;
谢谢,有钱
【问题讨论】:
-
您在分配
$data的地方引用错误 - 只是在 SO 上还是在您的源代码中?
标签: php xml upload curl google-api