得实际的Facebook和Twitter的个人资料图片网址Fle

得实际的Facebook和Twitter的个人资料图片网址Fle

本文介绍了获得实际的Facebook和Twitter的个人资料图片网址Flex的安全策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示来自Facebook和Twitter的个人资料图片。对于Facebook来说,我收到的网址是这样的(而不是实际的网​​址):

I'm trying to display the profile images from both facebook and twitter. For facebook, the URLs I'm receiving are something like this (not actual urls):

http://graph.facebook.com/965412145/picture

,然后重定向到实际的网址是这样的:

Which is then redirected to the 'actual' url like this:

http://profile.ak.fbcdn.net/hprofile-ak-snc4/370471_9631690_1796253478_r.jpg

我也这样做与Twitter,用同样的问题(重定向的URL)。

I'm also doing this with twitter, with the same issue (redirected url).

所以,当我加载图像,它加载的罚款。但是,当我合上容器图像中,然后我得到的安全沙箱冲突。

So, when I load the image, it loads fine. But when I close the container that the image is in, then I get the security sandbox violation.

我可以让这一切工作,如果我是从实际的形象URL添加URL是这样的:

I can get this all to work if I add the URL from the 'actual' image url like this:

request = new URLRequest("http://profile.ak.fbcdn.net");
loader = new Loader();
context = new LoaderContext();
context.checkPolicyFile = true;
loader.load(request, context);

然而,在运行时,我真的不知道真实形象的网址是什么,所以我可以在c在该领域不硬$ C $(我也不希望)。

However, at run time, I do not actually know what the 'actual' image url is, so I can't hard-code that domain in (nor do I want to).

有没有一种方法来获得实际的URL(从内部弯曲)的图像,这样我可以添加正确的域到的LoaderContext?

Is there a way to get the actual url (from within flex) of the image so that I can add the correct domain to the loadercontext?

任何想法AP preciated!

Any ideas are appreciated!

推荐答案

如果我理解正确的话,你的问题是,你正试图从重定向到另一个源的URL加载图像。你需要知道的重定向的URL是,这样你就可以加载策略文件,使操纵图像的字节数。

If I understand correctly, your problem is that you're trying to load an image from a URL that redirects to another source. You need to know what the redirected URL is, so you can load a policy file that allow manipulation of image bytes.

如果我理解正确的话,你需要通过侦听完成事件(或错误事件)来检测重定向的URL,然后引用与LoaderInfo.url 属性。此属性将反映在重定向的情况下结束的URL。例如,您将有code这样的监听器:

If I've understood correctly, you need to detect the redirected URL by listening for the COMPLETE event (or an error event), then reference the LoaderInfo.url property. This property will reflect the end URL in the event of redirects. For example, you would have code like this in the listener:

var ldr:LoaderInfo = event.target as LoaderInfo;
var url:String;
try
{
    url = ldr.url;
    // Split off URL base, load policy file, etc here
}
catch (e:Error)
{
    // Unable to detect final URL due to error.
}

这篇关于获得实际的Facebook和Twitter的个人资料图片网址Flex的安全策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 21:53