0
以下功能應輸出Vimeo縮略圖。它沒有返回任何東西。我已經測試了$id
,它正在傳入該功能,並且它是視頻的有效vimeo ID。當我用 $out = 'hello';
替換$out = xxx
時,沒有任何東西出來。這導致我相信在xml調用中沒有記錄被返回。捲曲7.12.1被安裝。還有什麼可能是一個問題呢?CURL/PHP/Apache - 爲什麼CURL/Simplexml請求不能使用Vimeo?
function vimeo_thumbnail()
{
global $TMPL, $DB, $SESS;
$video_id = $TMPL->fetch_param('id');
if(!$video_id) {
return;
}
// API endpoint
$api_endpoint = 'http://www.vimeo.com/api/v2/video/'.$video_id.'.xml';
// Curl helper function
function curl_get($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
$return = curl_exec($curl);
curl_close($curl);
return $return;
}
// Load the user info and clips
$video_info = simplexml_load_string(curl_get($api_endpoint));
foreach ($video_info->video as $video) {
$out = '<img src="'.$video->thumbnail_medium.'" />';
}
$this->return_data .= $out;
}
謝謝Sab。原來我在PHP4服務器上,所以simplexml_load_string不會'工作。 你可能會給我一個替代品嗎? – user151257 2009-10-08 04:23:26
也許這將有助於? http://www.webmaster-talk.com/php-forum/170192-problem-with-simplexml_load_string-and-php4.html – 2009-10-08 10:39:05