0

Sencha Touch를 사용하여 YouTube v3 검색 API를 어떻게 쿼리합니까? (: 필요합니다 참고) : 다음은 직접 브라우저에서 발행 할 때 잘 작동 샘플 URL입니다 "https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&type=video&channelId=UC3djj8jS0370cu_ghKs_Ong&key=MY_KEY"youtube api v3 Sencha Touch 2의 CORS 지원

엽차 터치 스토어 아약스 프록시를 사용하여로드 할 때 동일한 URL이 실패하지만. 이 URL에 대해 OPTIONS 전화가 걸려 왔고 GET이 중단 된 것으로 보입니다.

youtube V3 google apis로 작업하기 위해 Sencha 터치 스토어에 필요한 것은 무엇입니까? 나는 YouTube V3 API에 jsonp 지원을 찾지 못했습니다. 나는이 같은이 API를 사용했다

답변

4

,

proxy: { 
      type: 'ajax', 
      url: 'https://www.googleapis.com/youtube/v3/search', 
      useDefaultXhrHeader: false, 
      extraParams: { 
       part: 'snippet', 
       q: 'ambarsariya', 
       regionCode: 'IN', 
       maxResults: 30, 
       key: 'your_key' 
      }, 
      reader: { 
       type: 'json', 
       rootProperty: 'items' 
      } 
     } 

한가지 더 당신이 할 일은 당신이이 상점의 모델에 idProperty을 설정 한 그게 전부입니다. 사용 된 모델의 내부 구성

idProperty: 'videoId',// its better if this name is not same as any fields name 
     fields: [{ 
      name: 'snippet' 
     }, { 
      name: 'thumbnail', 
      mapping: 'snippet.thumbnails.default.url' 
     }, { 
      name: 'title', 
      mapping: 'snippet.title' 
     }] 

희망이 문제를 해결합니다.

+0

Thnx. 내 경우에는'useDefaultXhrHeader : false'가 누락되었습니다. –

2

잘 작동합니다.

STORE : - 그것은 또한 또한 JSONP 프록시 잘 작동

Ext.define('MyApp.store.videos', { 
     extend: 'Ext.data.Store', 
     model: 'MyApp.model.Video', 
     config: { 
      autoLoad: true, 
      proxy: { 
       type: 'ajax', 

       //This is required to enable cross-domain request 
       useDefaultXhrHeader: false, 
       url: 'https://www.googleapis.com/youtube/v3/search', 

       extraParams: { 
        part: 'snippet', 
        q: "Enrique", //Query string 
        regionCode: 'IN', 
        maxResults: 30, 
        key: 'AIzaSyD6FvoLaIFqyQGoEY4oV7TEWGAJSlDd1-8' 
       } 
      } 
     } 
    }); 

This is the model used by the above store. 

MyApp.model.Video:- 

Ext.define('MyApp.model.Video', { 
    extend: 'Ext.data.Model', 
    requires: [], 

    config: { 
     idProperty: 'videoId', 
     fields: [{ 
      name: 'id' 
     }, { 
      name: 'videoId', 
      mapping: 'id.videoId' 
     }] 
    } 
}); 

,

단지 유형 변경 : 프록시 내부 JSONP를하고 useDefaultXhrHeader의 설정을 제거합니다.