获取 Flex 安全策略的实际 Facebook 和 Twitter 个人资料图像 URL
我正在尝试显示来自 facebook 和 twitter 的个人资料图像。对于 facebook,我收到的 URL 是这样的(不是实际的 url):
http://graph.facebook.com/965412145/picture
然后重定向到“实际”的 url,如下所示:
http://profile.ak.fbcdn.net/hprofile-ak-snc4/370471_9631690_1796253478_r.jpg
我也在 twitter 上这样做,有同样的问题(重定向的 url)。
因此,当我加载图像时,它加载得很好。但是,当我关闭图像所在的容器时,我会遇到安全沙箱违规。
如果我像这样从“实际”图像 url 添加 URL,我就可以让这一切正常工作:
request = new URLRequest("http://profile.ak.fbcdn.net");
loader = new Loader();
context = new LoaderContext();
context.checkPolicyFile = true;
loader.load(request, context);
但是,在运行时,我实际上并不知道“实际”图像 url 是什么,所以我无法硬编码该域(我也不想)。
有没有办法获取图像的实际 url(来自 flex 内),以便我可以将正确的域添加到 loadercontext 中?
任何想法表示赞赏!
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
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.
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);
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).
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?
Any ideas are appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您的问题是您尝试从重定向到另一个源的 URL 加载图像。您需要知道重定向 URL 是什么,以便加载允许操作图像字节的策略文件。
如果我理解正确,您需要通过侦听
COMPLETE
事件(或错误事件)来检测重定向的 URL,然后引用LoaderInfo.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.
If I've understood correctly, you need to detect the redirected URL by listening for the
COMPLETE
event (or an error event), then reference theLoaderInfo.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: