这是你如何解决这个问题的例子:
// Include the Auth string in the headers
// Together with the API version being used
$headers = array(
"Authorization: GoogleLogin auth=" . $auth,
"GData-Version: 3.0",
);
// Make the request
curl_setopt($curl, CURLOPT_URL, "http://docs.google.com/feeds/default/private/full");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
curl_close($curl);
// Parse the response
$response = simplexml_load_string($response);
// Output data
foreach($response->entry as $file)
{
//now you can do what ever if file type is a txt
//if($file->title =="txt")
// do something
else
// do soething
echo "File: " . $file->title . "<br />";
echo "Type: " . $file->content["type"] . "<br />";
echo "Author: " . $file->author->name . "<br /><br />";
}
我发现在卷曲“CURLOPT_HEADERFUNCTION”,让您为标题回调函数的一个选项,但你不能从回调内部取消请求。你会得到这样的错误:“尝试在良好的编程设计中关闭cURL句柄回调” – Greg 2009-12-04 21:50:05
,不应该为“正常”操作抛出异常,因为通常异常在算法上是昂贵的。他们应该只适用于很少发生的操作,如错误或不正确的行为。 – zmo 2012-05-27 16:35:53
要放弃从为'CURLOPT_HEADERFUNCTION'或其他'CURLOPT_ * FUNCTION'选项定义的回调函数内下载响应流,请将您的回调函数返回为'-1'。 – lafor 2013-07-03 10:39:46