Facebook的API:为什么我可以加载用户的形象关闭一个领域,但不是其他?加载、形象、领域、不是

2023-09-08 12:44:23 作者:大叔的仙女棒

图片1是fbcdn-photos-a.akamaihd.net

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

图片2是fbcdn-sphotos-a.akamaihd.net

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

的跨域文件是相同的:

https://fbcdn-sphotos-a.akamaihd.net/crossdomain.xml

https://fbcdn-photos-a.akamaihd.net/crossdomain.xml

我可以加载图像拇指(这是在服务器1),但我不能加载完整图像(这是在服务器2)。我得到引发SecurityError:错误#2123:安全沙箱冲突

I can load image thumbs (which are on server 1), but I cannot load the full images (which are on server 2). I get SecurityError: Error #2123: Security sandbox violation.

2小时我一直在玩的LoaderContext设置的Security.allowDomain,并在Security.loadPolicyFile。没有给出。

For 2 hours I've been playing with LoaderContext settings, Security.allowDomain, and Security.loadPolicyFile. Nothing gives.

推荐答案

我也挣扎蒙山这个前几天......但所有的突然,它的工作由

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

加入这个地方的时候,我的应用程序inits:

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);
}