2016-06-20 10 views
-1

Google APIを使用して祝日カレンダーにアクセスしようとしています。私はいくつかのQからお読みください&公開カレンダーへのアクセスには承認が必要なく、APIキーで特定の国のすべての休日を取得できます。以下は、Webブラウザで入力したURLで、OAuthなしですべての休日をダンプできるようになっています。 https://www.googleapis.com/calendar/v3/calendars/en.canadian%23holiday%40group.v.calendar.google.com/events?key=myAPIkey Googleが生成したAPIキーでmyAPIkeyを置き換えると、すべてのカナダの休日がブラウザにダンプされます。 したがって、以下のFlexプログラムを書きましたが、返されたevt.resultにはデータが含まれていません。私は別のcalendarService.resultFormatを試しましたが、まだ動作していません。助けてください。FlexがOAuthなしでGoogle APIを使用して公開カレンダーにアクセスする

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="doInit()"> 
    <fx:Script> 
     <![CDATA[ 
      import mx.rpc.Responder; 
      import mx.rpc.events.ResultEvent; 
      import mx.rpc.http.HTTPService; 

      private var calendarService:HTTPService; 
      private var success:Boolean = true; 

      protected function doInit():void 
      { 
       calendarService = new HTTPService(); 
       calendarService.method = "GET"; 
       //calendarService.resultFormat = HTTPService.RESULT_FORMAT_ARRAY; 
       //calendarService.resultFormat = HTTPService.RESULT_FORMAT_E4X; 
       calendarService.resultFormat = HTTPService.RESULT_FORMAT_FLASHVARS; 
       //calendarService.resultFormat = HTTPService.RESULT_FORMAT_OBJECT; 
       //calendarService.resultFormat = HTTPService.RESULT_FORMAT_TEXT; 
       //calendarService.resultFormat = HTTPService.RESULT_FORMAT_XML; 
      } 

      public function getCalendarByCountry():void 
      { 
       calendarService.url = "https://www.googleapis.com/calendar/v3/calendars/en.canadian%23holiday%40group.v.calendar.google.com/events?key=<myAPIkey>"; 
       respCalendar.token = calendarService.send(); 
       respCalendar.addEventListener(ResultEvent.RESULT, onCalendarsResponse); 
       respCalendar.addEventListener(FaultEvent.FAULT, onCalendarsFault); 
      } 

      private function onCalendarsResponse(evt:ResultEvent):void 
      { 
       respCalendar.removeEventListener(ResultEvent.RESULT, onCalendarsResponse); 
       success = true; 
      } 


     private function onCalendarsFault(evt:FaultEvent):void 
     { 
      respCalendar.removeEventListener(ResultEvent.RESULT, onCalendarsFault); 
      success = false; 
     } 

     ]]> 
    </fx:Script> 
    <fx:Declarations> 
     <mx:CallResponder id="respCalendar"/> 
    </fx:Declarations> 

    <mx:Button label="Get" click="getCalendarByCountry()"/> 

</mx:Application> 
+0

あなたはデータなしでは何を意味するのですか?ヌルですか?それとも空の文字列ですか?フォールトリスナーを追加して、それがいくらか明確になっているかどうかを確認してください。 RESULT_FORMAT_OBJECTが必要ですか?返される値はXMLですが、ActionScriptオブジェクトのツリーとして解析されます。 –

+0

nullです。障害リスナーを追加しましたが、実行されませんでしたRESULT_FORMAT_OBJECTを持っている特別な理由はありません。私はちょうど私が古いと知っているhttps://sujitreddyg.wordpress.com/tag/flex-code-for-google-calendar/に従っています。 RESULT_FORMAT_FLASHVARSを使用するように変更され、今回はevt.token.resultがオブジェクトであり、私が求めたカナダの休日のすべての情報があります。これは、JSONオブジェクトのように見えますが、\ nとこのような望ましくないダブルqoutes(\ n "kind": "calendar#events"、\ n "summary": "Canada in Holidays"実際のJSONを渡すにはgoogle? – dennislee

答えて

関連する問題