0
這是一個非常大的問題,但 這是我的HTML如何從YouTube的響應獲得totalResults?
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/core-ajax/core-ajax.html">
<polymer-element name="test-element" attributes="q">
<template>
<core-ajax auto url="https://www.googleapis.com/youtube/v3/search"
params='{"part":"snippet", "q":"{{qry}}", "maxResults":"{{vidMaxResults}}",
"key":"{{key}}"}' handleAs="json" response="{{response}}" method='GET'></core-ajax>
<template repeat="{{item in response.items}}">
<div>
<p>{{item.snippet.title}}</p>
</div>
</template>
<template bind>
<span>Total results: {{item.totalResults}}</span>
</template>
</template>
<script>
Polymer({
response: null,
vidMaxResults: 10,
qry: 'Hello',
key: ''
});
</script>
</polymer-element>
我要如何從JSON響應的使用totalResults?
如果maxResults沒有作爲參數給出(如數千結果,但我想每次只查看10個),我如何獲得管理所有數據?
此外,我如何獲得視頻本身的鏈接爲每個視頻結果(而不是youtube鏈接)?
我是新來的使用這些聚合物和youtube api所以請給我一些基本的想法。
感謝提前:)
謝謝,我實際上忘記了「pageInfo」。另外我也會研究。如果您也瞭解原始視頻網址,我會非常高興。不過謝謝。 –