- Home /
Twitter feed in webplayer stops working when I upload my game
I am making a game that is based on a twitter feed and supposed to run in webplayer. I'm using the WWW class to send the http request, and then parse the JSON object that is sent back with my own method.
When I build the webplayer, and run it from my local hard drive, it still works, but when I upload it to the web (in this case a Dropbox public folder) and open it from the online URL, it stops recieving the tweets.
AFAIK there are no debugging options at the point where it's uploaded, so I don't have any error message.
Could it be that this is the webplayer security sandbox? I read the page about it, but if it was a security sandbox thing, why would it still work if I run the webplayer from my local drive?
Does anyone have an idea what it could be and how to fix it?
Answer by Stormizin · May 24, 2013 at 07:42 PM
In this case, you would need to place a crossdomain.xml file at the root of the requested link domain like this: http://twitter.com/dir
Imagine the WWW without this security, everyone will pull everything from any link and too much errors will appear.
Thats WHY all this polices: The socket and WWW security features exist to protect people who install the Unity Web Player. Without these restrictions, an attack such as the following would be possible:
Bob works at the white house. Frank is evil. He writes a unity webgame that pretends to be a game, but in the background does a WWW request to http://internal.whitehouse.gov/LocationOfNuclearBombs.pdf. internal.whitehouse.gov is a server that is not reachable from the internet, but is reachable from Bob's workstation because he works at the white house. Frank sends those pdf bytes to http://frank.com/secretDataUploader.php Frank places this game on http://www.frank.com/coolgame.unity3d Frank somehow convinces Bob to play the game. Bob plays the game. Game silently downloads the secret document, and sends it to Frank.
So you do think it is the security sandbox? But I can't really by any legal means place my crossdomain.xml on the Twitter domain, right?
Your right bro. What you can do its parse the HT$$anonymous$$L tags from the app.
Sorry, I don't get it. http://twitter.com/dir is a Twitter account. I'm currently using tweets from #belieber.
Actually i mean /dir (directory) of the twitter domain to put the crossdomain.xml file. :P
Umm, so what exactly was then your suggestion how to work around my problem?
Answer by waspfarmer2 · May 30, 2013 at 11:05 AM
If you need to get at twitter, have unity webplayer inject javascript into a the browser and get the browser to fetch the tweets and feed them back into the webplayer.
We've done something similar to overcome the restriction on certain includes. So the user could save an image file we base64 the byte array and injected it in the browser with a piece of javascript which would bring up the browser's save dialog.
This should get you started. With the injection part.
public TextAsset javascript;
void OnEnable ()
{
Application.ExternalEval (javascript.text);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613102852im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Security.PrefetchSocketPolicy does not work in debug session? 0 Answers
Webplayer sandbox security policy: When do I prefetch security policy? 1 Answer
Help on Security Sandbox of the Webplayer 0 Answers
Protecting my assetbundles 1 Answer
How often should a webplayer communicate with the server? 2 Answers