Flash REST woes: passing headers through php proxy -


i'm writing actionscript3 flash game, needs access rest services specified sponsor (buyer of game) - things highscores etc. know how use urlloader, urlrequest, set urlrequestheader.

unfortunately sponsor on shared hosting , can't put crossdomain.xml in server root, can't connect localhost flash game (same origin policy). learned there way connect rest api proxying calls through php file on different server.

so have proxy.php file on private server, , calling like:

www.myserver.pl/scripts/proxy.php?url=http%3a%2f%2sponsorserver.hosting.com/api/init.json                                   (url=urlencoded address) 

it connects (returns http 200), don't know yet how pass custom headers init.json script; tried combinations sending them through , post, calling script through , post (using restclient ff extension).

this proxy.php:

$getvars = 'myparam1=3;&myparam2=data;'; // test purposes $url = $_get['url'] . '?' . $getvars; $session = curl_init($url);  curl_setopt($session, curlopt_header, true); curl_setopt($session, curlopt_returntransfer, true);  $response = curl_exec_follow($session);  echo $response;  curl_close($session); 

unfortunately server has base_dir != '' can't set curlopt_followlocation , use curl_exec, hence curl_exec_follow (taken answer: https://stackoverflow.com/a/10835824/2492808). why variables not picked init.json? says doesn't see myparam1 , myparam2. unfortunately can't change php.ini on server, , need way make working, can integrate , test sponsor's rest api ide. thanks!

edit: stupid, it's not variables want send sponsor script, http headers. i've removed $getvars , added:

curl_setopt ($session, curlopt_httpheader, array('myparam1=3','myparam2=data')); 

before curl_exec_follow , inside, before every new curl_exec call, theoretically should set headers , make them through. unfortunately, script still doesn't see headers :(

also, according php manual, tried removing base_opendir restriction putting .htaccess in www.myserver.pl/scripts/:

<ifmodule mod_php5.c>   php_value open_basedir "" </ifmodule> 

but it's not changing anything, don't have

"allowoverride options" or "allowoverride all" privileges so

so curlopt_followlocation still illegal.

unfortunately can't change php.ini on server, , need way make working, can integrate , test sponsor's rest api ide. thanks!

useless excuse these days. buy $15 per month server hosted on amazon cloud. it's easier spend $15 spend hour writing code solvable problem. spending $10 anyway on shared hosting plan.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -