views:

86

answers:

5

The company I work for has their own Flash based video player and the question I get from our execs is "Can we tell what website our player is embedded on?"

At first, I hypothesized I could use Apache mod_rewrite, extract the HTTP_REFFER, and append it to the end of the requested URL. So as the browser gets http://.../viewer.swf, I could slap on ?ref=otherdomain.com

However, I don't think our CDN will cater to our htaccess file. Plus, mostly all the access_log entries show a dash rather than the domain.

So I'm casting this question our here to see if I catch any ideas or solutions. Currently, everything points to 'not possible'.

A: 

Caveat: I don't know flash at all...

Not sure exactly how you need to capture this, but is it possible for your flash player to grab the URL on the client (or containing frame maybe?) and then POST/PUT/GET that back to the server? I was thinking it could do this after retrieving the viewer.swf but prior to opening the content stream (underlying assumption of how players work).

Not sure if this is useful or not.

confusedGeek
No, it's not possible in Flash itself that I'm aware of.
John Giotta
A: 

Use ExternalInterface, which can make calls to javascript functions in the parent page:

import flash.external.ExternalInterface;

var url:String = ExternalInterface.call('window.location.href.toString');

The only issue with this is that if the user has javascript turned off, then the url value will be null.

wmid
This is a method I was aware of, but unfortunately, allowScriptAccess is set to sameDomain and generally set to never by sites like MySpace.com. So its not very reliable without exploiting the remote site's security.
John Giotta
A: 

The referer is usually stored in the access log file for each request, isn't it?

Wouldn't it be the easiest thing to grep your CDN's access log file for calls to the embedded movie player?

If that's not an option: I'm not a Flash man, but it must be possible to get hold of the movie's referer inside the movie using Actionscript somehow, without getting into trouble with cross-domain security. After all, it's information that is available when the request to the movie is made.

Pekka
Now I haven't tested it yet and I plan to soon, so I was going to set the URL to our origin server then pull the logs. Yet, the access logs that do register requests, the "column" where you would see the referring domain is only a "-". So I'm guessing that the Apache server has no idea where the request came from since it's internal to Flash.I'll definitely follow-up if my tests reveal a different expectation.
John Giotta
Ah, I see, I overread that part, sorry. From what I can see from a quick glance into Google, this really seems to be an issue. I really don't understand why the browser wouldn't send a referer header along with the request to the SWF. I'd be interested to hear if anything comes up in your research.
Pekka
A: 

Could be wrong on this but I think you can just get it like this. Put this code at the root level of your application (on the timeline on stage or in your document class):

trace(this.loaderInfo.url)

If I'm not wrong that'll help you. I built something similar for a video service years ago, where the video name that it pulled was derived from the name of the folder it was in. Let me know if that helps!

Edit: oh, right - once you have that, it's pretty simple to write a web service that'll accept that as a string and store it in a DB or whatever. You might even be able to tie it into an analytics service - MyAnalyticsFunction.call(myUrl) - and that'll take care of it for you, but that depends on how you're set up.

But, short answer - yes, .swfs know where they live.

Myk
Yes, a SWF knows where it lives, but only it's absolute URL (where the file resides). loaderInfo.url will not return the address from where the SWF being viewed.
John Giotta
Oh, sorry - I wasn't quite appreciating the distinction.This is a little bit hacky, but if it's really important you could make the javascript window.location call as part of your embed code and pass it in as a FlashVar, then go from there? That way at least the JS isn't coming from the .swf, though I dunno how well that would work. Good luck, and let us know if you figure something out!
Myk
A: 

I was able to devise a method of obtaining referrer using mod_rewrite. The question below is in relation to method. Basically, by using rewrite rules I can grab the referrer then redirect to the actual SWF with an appended query string.

http://stackoverflow.com/questions/2320111/is-it-possoble-to-obtain-the-hostname-only-from-http-referer-with-mod-rewrite

John Giotta