Facebook API: Why can I load a user's image off one domain but not another?

前端 未结 5 922
夕颜
夕颜 2021-01-16 05:07

Image 1 is at fbcdn-photos-a.akamaihd.net

Image 2 is at fbcdn-sphotos-a.akamaihd.net

The crossdomain files are identical:

https://fbcdn-sphotos-a.aka

5条回答
  •  长情又很酷
    2021-01-16 05:44

    I too was struggling whith this a few days ago... But the all of sudden, it worked by

    adding this somewhere when my app inits:

            Security.loadPolicyFile("http://graph.facebook.com/crossdomain.xml");
            Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
            Security.allowDomain("*");
            Security.allowInsecureDomain("*");
    

    And then i used this to get the picture:

    public function getProfilePicture():void {
                var myLoader:Loader = new Loader();
                myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
                    pic.bitmapData = Bitmap(myLoader.content).bitmapData;
                });
                var fileRequest:URLRequest = new URLRequest("http://graph.facebook.com/" + this.uid + "/picture");
                var lc:LoaderContext = new LoaderContext();
                lc.checkPolicyFile = true;
                myLoader.load(fileRequest, lc);
    }
    

提交回复
热议问题