我想創建一個網站,使用viemo api來搜索視頻,然後以XML格式輸出它們。我開局良好,但現在我陷入困境。用戶輸入被髮布,但沒有結果顯示Firebug控制檯上了......Vimeo API集成
這裏是我的VIMEO API集成.PHP:
<?
include('connect.php');
$video_id= $_POST['text'];
$url = 'http://vimeo.com/api/rest/v2';
$url .= '?';
$url .= 'method=vimeo.videos.search&';
$url .= 'oauth_consumer_key='.$api_key2.'&';
$url .= 'per_page=10&';
$url .= 'query='.$video_id.'&';
$url .= 'sort=relevant&';
$url .= 'full_response=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$curl_response = curl_exec($ch);
curl_close($ch);
$xmlObject = simplexml_load_string($curl_response);
$title= 'title';
$id = 'id';
$video_url = 'videosurl';
$thumbnails = 'thumbnail[1]';
$outputXML .= "";
$outputXML .= "<rsp>\n";
foreach($xmlObject->videos as $video) {
$videoTagBegin = "\t<video>\n";
$urlXML = "\t\t<videosurl>".$video->attributes()->$video_url."</videosurl>\n";
$titleXML = "\t\t<title>".$video->attributes()->$title."</title>\n";
$thumbXML = "\t\t<thumbnail>".$video->attributes()->$thumbnails."</thumbnail>\n";
$videoTagEnd = "\t</video>\n";
$outputXML .= $videoTagBegin.$titleXML.$thumbXML.$urlXML.$videoTagEnd;
}
$outputXML .= "</rsp>";
print $outputXML;
?>
任何幫助,將不勝感激。我完全卡住了。
這是我的JS它是否有助於在所有....
function closeDivs(e) {
e.preventDefault();
$('').empty();
};
$(document).ready(function() {
$('#searchbtn').bind('click' || 'enter',function(e) {
if ($.trim($('#searchBox').val()) !== '') {
$('#videos').empty();
closeDivs(e);
$('#videos').append('<img src="img/loading.gif" alt="loading" class="loading" />');
getEvents(e);
getVideos(e);
}
});
function getEvents(e) {
e.preventDefault();
var text = 'event_id='+$('#searchBox').val();
$.ajax({
url: 'getEvents.php',
dataType: 'xml',
type: 'POST',
data: text,
success: function(data) {
},
error: function(data) {
console.log('Error: ' + data);
}
})
};
function getVideos(e) {
e.preventDefault();
var text = 'video_id='+$('#searchBox').val();
$.ajax({
url: 'getVideos.php',
dataType: 'xml',
type: 'POST',
data: text,
success: function(data) {
},
error: function(data) {
console.log('Error: ' + data);
}
})
};
});
你在curl_response得到任何東西 – 2012-04-10 19:42:06
號在Firebug顯示任何內容,除了用戶輸入已發佈。它確實說錯誤:[對象對象]。但就是這樣。 – LE12 2012-04-13 16:49:56
它可能是一個授權問題?我一直很關心OAuth的東西。 – LE12 2012-04-13 16:54:29