Tuesday, March 30, 2010

Flickr API & crossdomain.xml

My flickr stream is not loading onto the page. I am using the following code to make it work:

Security.allowDomain(''http://api.flickr.com/crossdomain.xml'');
Security.loadPolicyFile(''http://api.flickr.com/crossdomain.xml'');

I also did always allow in the HTML. Is there a problem with that code?

Flickr API %26 crossdomain.xml

Deleted.

Sorry, there are cross domains there at http://api.flickr.com/crossdomain.xml - forum links added '');''

Flickr API %26 crossdomain.xml

Since there is crossdomain. xml that allows access from any domain, what makes you think that it doesn't stream because of security issues?

I was getting an error when I published it originally from flash.. and when I publish the .swf file the images do load and it works fine. When I add the same file to the server - nothing loads at all. It doesn't even try to load... What type of error do you think it could be?

What error do you get when you publish swf?

When I use this code instead of the 2 lines from my original post:

System.security.loadPolicyFile(''http://farm1.static.flickr.com/crossdomain.xml'');

I get this error: 1119: Access of possibly undefined property security through a reference with static type Class.

This error is legitimate for there is no System.security - syntax in the original post is proper.

Why do you think that you cannot stream because of of the security issues? What kind of assets do you stream?

Also, I have noticed that address has ''farm1'' prefix. If they redirect requests to different servers - you need to get policy from corresponding address too. Policy from farm1 will not work if asset is on farm2, farm3, etc.

Thank you Andrel1!

I needed to call them all. This code worked:


Security.loadPolicyFile(''http://api.flickr.com/crossdomain.xml'');
System.security.loadPolicyFile(''http://farm1.static.flickr.com/crossdomain.xml'');
System.security.loadPolicyFile(''http://farm2.static.flickr.com/crossdomain.xml'');
System.security.loadPolicyFile(''http://farm3.static.flickr.com/crossdomain.xml'');
System.security.loadPolicyFile(''http://farm4.static.flickr.com/crossdomain.xml'');

You are welcome.

I would like to suggest you make it more dynamic. What if they introduce farm22 server in their load balancing and you don't have explicit security check for it?

You may want to explore checkPolicyFile = true property on requested asset (LoaderContext, NetStream, etc.) directly. The beauty of this approach is that Flash does it automatically only once for each url - so if you request the next asset from the same url and policy is checked - Flash will not do it again, but if it is a new url - it will. You don't have to worry about where your assets come from.

No comments:

Post a Comment