-
1. Re: Cross Domain policiy issue...
kglad Nov 13, 2012 6:07 AM (in response to Karim Bizid)1 person found this helpfulthe xml you're trying to load is on twitter.com so loading a policy file from drgroove.v7 isn't going to work.
you need a policy file on twitter.com over which you have no control.
again, use a php gateway.
p.s. please mark helpful/correct responses in this and your duplicate thread that you started yesterday.
-
2. Re: Cross Domain policiy issue...
Karim Bizid Nov 13, 2012 6:59 AM (in response to kglad)Ok...
I've changed:
System.security.loadPolicyFile("http://drgroove.v7productions.nl/crossdomain.xml");
into:
System.security.loadPolicyFile("https://www.twitter.com/crossdomain.xml");
The crossdomain file on Twitter.com looks like this.
But it still won't work.
I seriously do not have a clue how to use a PHP gateway.
Can you suggest me a tutorial?
I also saw some Google result that it might work without a gateway file.
Hope you can help me out... It's killing me...
-
3. Re: Cross Domain policiy issue...
kglad Nov 13, 2012 7:02 AM (in response to Karim Bizid)there is no crossdomain.xml on twitter any more so your loadPolicyFile isn't going to work.
you already have the needed php file if what you reported in your previous thread is correct.
-
4. Re: Cross Domain policiy issue...
Karim Bizid Nov 13, 2012 7:11 AM (in response to kglad)Is this not usefull?
<cross-domain-policy xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">
<allow-access-from domain="twitter.com"/>
<allow-access-from domain="api.twitter.com"/>
<allow-access-from domain="search.twitter.com"/>
<allow-access-from domain="static.twitter.com"/>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-http-request-headers-from domain="*.twitter.com" headers="*" secure="true"/>
</cross-domain-policy>
I did not post a php file in the previous thread, since I don't haven one.
I only have the link to it out of AS because I used a couple of lines AS from someone else on the internet.
The document twitter.php does not exist, yet.
-
5. Re: Cross Domain policiy issue...
kglad Nov 13, 2012 7:34 AM (in response to Karim Bizid)1 person found this helpfulto use a cross-domain policy file, you must upload the policy file to the server that is supplying the data. that policy file must give permission to access its data from the domain that hosts your swf.
so, you need to upload a policy file to twitter.com that allows drgroove.v7 to access twitter's data. because you cannot upload anything to twitter.com you cannot use a cross-domain policy file to solve this problem.
you must use a script gateway. in your previous thread, you showed code that loaded twitter.php and you stated that worked when you tested it locally. is that correct?
-
6. Re: Cross Domain policiy issue...
Karim Bizid Nov 15, 2012 7:54 AM (in response to kglad)Ok... I understand.
But I did not post a PHP script... I do not have a PHP script.
Do you happpen to know a good tut on this issue, because I'm not that expirencied to created that myself.
-
7. Re: Cross Domain policiy issue...
kglad Nov 15, 2012 9:46 AM (in response to Karim Bizid)1 person found this helpfulhere is the code for a gateway.php file contents:
<?php
$requestURL = $_POST['requestURL'];
$cr = curl_init($requestURL);
curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
$returnS = curl_exec($cr);
curl_close($cr);
echo $returnS;
?>
open notepad or some other plain text editor, and paste that code into a new file saved as gateway.php
make sure your saved file is gateway.php and not something like gateway.php.txt
then in your fla file use:
var sendLV:LoadVars=new LoadVars();
var receiveLV:LoadVars=new LoadVars();
receiveLV.onData=function(src){
some_tf.text=src; // <- add a textfield named some_tf to your fla while your debugging so you can see what's returned from the php script
}
sendLV.requestURL="https://api.twitter.com/1/trends/daily.json";
sendLV.sendAndLoad("gateway.php",receiveLV,"POST");
-
8. Re: Cross Domain policiy issue...
Karim Bizid Nov 18, 2012 7:37 AM (in response to kglad)Thanks!
Is not working yet, but I'm questioning the c_url support of my host.
Flash is not giving any errors, so that seems to be alright.
This is how I inserted your AS:
var sendLV:LoadVars=new LoadVars();
var receiveLV:LoadVars=new LoadVars();
receiveLV.onData=function(src){
some_tf.text=src; // <- add a textfield named some_tf to your fla while your debugging so you can see what's returned from the php script
}
sendLV.requestURL="https://api.twitter.com/1/trends/daily.json";
sendLV.sendAndLoad("gateway.php",receiveLV,"POST");
var loadXML:XML = new XML();
loadXML.ignoreWhite = true;
loadXML.onLoad = processXML;
loadXML.load("gateway.php"); //used when swf in placed on server
function processXML(loaded:Boolean)
{
if(loaded)
{
var node = this.firstChild;
tweet_1.text = node.childNodes[0].childNodes[2].firstChild;
tweet_2.text = node.childNodes[1].childNodes[2].firstChild;
tweet_3.text = node.childNodes[2].childNodes[2].firstChild;
tweet_4.text = node.childNodes[3].childNodes[2].firstChild;
var follower_count = node.childNodes[9].childNodes[11].childNodes[9].firstChild;// Creates variable
trace(follower_count); //loads variable into output
follower_count_txt.text = follower_count;// show follower count in text box
}
else
{
error_txt.text = "Error loading XML file";
}
for (i=0; i<follower_count; i++) // <-- problem occurs here
{
_root.attachMovie("tweep_mc", "tweep"+i+"_mc", i);
_root["tweep"+i+"_mc"]._x = 150 + random(500);
_root["tweep"+i+"_mc"]._y = 150 + random(500);
trace(i);
}
trace(i);
}
follow_btn.onRelease = function()
{
getURL("http:///twitter.com/studiodrgroove");
}
facebook_btn.onRelease = function()
{
getURL("http://www.facebook.com/pages/Studio-DR-Groove/415605851839285");
}
stop();
I'm only reading out the gateway .php file, but that is the file that's is providing the XML Twitter feed, right?
-
9. Re: Cross Domain policiy issue...
kglad Nov 18, 2012 9:33 AM (in response to Karim Bizid)do you have a textfield named some_tf displayed on stage? if yes, post a link to your embedding swf's html.
-
10. Re: Cross Domain policiy issue...
Karim Bizid Nov 18, 2012 1:12 PM (in response to kglad)Yes...
Here's a link to the embedded .swf:
http://puurgeluid.nl/twitter_test/
The upper box is a "tweet_1" box and the lower is the "some_tf" box.
Currently it's saying "undefined", but I have no idea why.
The URL I've inserted seems fine when I test it in my browser:
https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=tr ue&screen_name=karimbizid2&count=2 -
11. Re: Cross Domain policiy issue...
kglad Nov 18, 2012 3:26 PM (in response to Karim Bizid)1 person found this helpfulremove all the code except the code i suggested.
-
12. Re: Cross Domain policiy issue...
Karim Bizid Nov 19, 2012 7:42 AM (in response to kglad)I'm still seeing "undefined"
(http://puurgeluid.nl/twitter_test/)
Can I conlude that there's something wrong with the data from Twitter?
-
13. Re: Cross Domain policiy issue...
Karim Bizid Nov 19, 2012 8:06 AM (in response to Karim Bizid)I've been Googling on it...
Do I need some kind of authentification for getting statusses in Flash, this way? -
14. Re: Cross Domain policiy issue...
kglad Nov 19, 2012 8:08 AM (in response to Karim Bizid)not really. i conclude you have trouble following directions.
you're still using your twitter request. this is what you would see if you used the code i suggested: http://www.kglad.com/Files/forums/test2.html
-
15. Re: Cross Domain policiy issue...
Karim Bizid Nov 19, 2012 8:29 AM (in response to kglad)I've copied your code and deleted every other action script in my movie.
The only thing I've changed at first is the requets URL, but even now I changed it back I'm still seeing "undefined".
-
16. Re: Cross Domain policiy issue...
kglad Nov 19, 2012 10:09 AM (in response to Karim Bizid)what do you see at: http://www.kglad.com/Files/forums/test2.html