2011-01-20 9 views
0

httprequestからhttpsアドレスへの結果を取得しようとすると、相当な苦労があります。 アドレスからポリシーファイルをロードしていますが、まだ2048セキュリティエラーが発生しています。フレックスを使用したhttpsアドレスからのポリシーファイルのロード

私のpreinitilizeハンドラでポリシーファイルをロードします。

private function preint(e:FlexEvent):void 
      { 
       Security.loadPolicyFile("https://api.soundcloud.com/crossdomain.xml"); 
      } 

私のサーバーは、私が必要とする特別なトークンをバック与え、その後、私は私がするURLRequestおよびURLLoaderクラスを使用して、必要なリソースへの要求を作成してみてください。

private function getprivatetracks():void 
     { 
       var url:String=new String("https://api.soundcloud.com/me/tracks?oauth_token=" + testapplicationparameters["oauth_token"]) 
      var req:URLRequest=new URLRequest() 
      req.contentType="application/x-www-form-urlencoded" 
      req.method=URLRequestMethod.GET; 
      req.url=url; 

      var loader:URLLoader=new URLLoader() 
      loader.dataFormat=URLLoaderDataFormat.TEXT; 
      loader.dataFormat="text"; 
      loader.load(req); 
      configureListeners(loader); 


     } 

URLをトレースしてブラウザに貼り付けても、結果は正常に表示されます。それは純粋にフラッシュのものです。 flex IDEからデバッグモードでswfを実行すると、要求は正常に機能します。この問題は、swfがサーバー上にある場合にのみ発生します。

私は一日のうちに頭を叩いてこれを理解しようとしました。

誰かが私が間違っているかもしれないことを示唆することができますか?

私は、フラッシュがhttpsをどのように処理するかについての基本的な知識が不足していると推測しています。私は、セキュリティエラーイベントをキャッチし、何のリダイレクトが起こっていないことを確認theresのを作るために、URLをチェックしてみたが、ハンドラが呼び出されることは決してありません

EDIT 1

Error: Request for resource at https://api.soundcloud.com/me/tracks?oauth_token=0000000NBfKiNXEYG00FWTUGAy5Uw68r by requestor from http://myserver/content/flash/soundcloud/sclive.swf is denied due to lack of policy file permissions. 

*** Security Sandbox Violation *** 
Connection to https://api.soundcloud.com/me/tracks?oauth_token=0000000NBfKiNXEYG00FWTUGAy5Uw68r halted - not permitted from http://myserver/content/flash/soundcloud/sclive.swf 
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://myserver/content/flash/soundcloud/sclive.swf cannot load data from https://api.soundcloud.com/me/tracks?oauth_token=0000000NBfKiNXEYG00FWTUGAy5Uw68r. 
    at sclive/getprivatetracks()[C:\flex_projects\sclive\src\sclive.mxml:74] 
    at sclive/authorize_result_handler()[C:\flex_projects\sclive\src\sclive.mxml:62] 
    at flash.events::EventDispatcher/dispatchEventFunction() 
    at flash.events::EventDispatcher/dispatchEvent() 
    at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:763] 
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:263] 
    at mx.rpc::Responder/result()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:46] 
    at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74] 
    at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.5.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:409] 
    at flash.events::EventDispatcher/dispatchEventFunction() 
    at flash.events::EventDispatcher/dispatchEvent() 
    at flash.net::URLLoader/onComplete() 

EDIT 2

!私はそれのためのハンドラを書いても、常にunhanled例外エラーが発生します。

+0

は、あなたが全体のエラーを投稿できる仕事shloud:

はしかし、私はちょうど、HTTP上のクロスドメインもあります気づきましたメッセージ? –

答えて

0

セキュリティ上の理由から、HTTPコンテンツがHTTPSコンテンツにアクセスすることを許可しないことをお勧めします。 したがって、soundcloudがHTTPコンテンツのデータへのアクセスを許可したい場合は、crossdomain.xmlに指定する必要があります(allow-access-fromタグのsecure = "false"属性を使用)。 だから、http://api.soundcloud.com/crossdomain.xml

私はあなたの代わりにHTTPSでこのURLを使用することをお勧めし、それが

+0

さて、サウンドクラウドのAPIを詳細にチェックしていないので、実際には言えません。しかし、API用のAS3ラッパーがあるようです: https://github.com/dorianroy/Soundcloud-AS3-API/wiki こちらのページでは、Security.loadPolicyFile( "https:/")を呼び出す必要はありません。 /api.soundcloud.com/crossdomain.xml "); –