I came up with this twitter project in flash, and once i was done and tried to put it online i ran into a sandbox error. From what i've read it looks like i just need to setup a php proxy file. Which I get and understand. All the tutorials i've been able to find were for simple urls with no GET data being passed in the URL. For my project the GET data is dynamic so i can't just put a set url in the php proxy and i dont understand php well enough to figure out how to get the get data into the proxy url.. so here's what i know how to edit in Flex:
heres a full example api call i would need to make:
http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=brybam&?page=1
and here is a php proxy script that was reccomended online:
<?php
$post_data = $HTTP_RAW_POST_DATA;
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);
$ch = curl_init( $_GET['url'] );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ( strlen($post_data)>0 ){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($ch);
$response_headers = curl_getinfo($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
header( 'Content-type: ' . $response_headers['content-type']);
print $response;
}
?>
Alright so getting started I just need to make the php script into a file something like twitter.php and just put it on my domain. Then I'm assuming in the URL box for the http service setup in Flex put and reenter it as something like this:
http://mydomain.com/twitter.php?screen_name=brybam&?page=1
SO what im asking is because my understanding of php is very limited, how exactly would I take the above script and make it capable of being passed
http://mydomain.com/twitter.php?screen_name=brybam&?page=1
with Flex and be able to take different potential arguments?
I think it may be something like
$page = $_GET['page'];
$screen_name = $_GET['screen_name'];
in the php file, but im not sure where i should be placing the variables into to make them part of the URL
im sure this is cake if you know php and it would be awesome if someone could help me out with this, thanks!
EDIT: I tried this, but got an error (the error is posted under what i tried)
<?php
$page = $_GET['page'];
$screen_name = $_GET['screen_name'];
$url = $_GET['url'];
$post_data = $HTTP_RAW_POST_DATA;
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);
$ch = curl_init("'url'?screen_name='$screen_name'&?page='$page'");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ( strlen($post_data)>0 ){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($ch);
$response_headers = curl_getinfo($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
header( 'Content-type: ' . $response_headers['content-type']);
print $response;
}
?>
error msg:
The response is not a valid XML or a JSON string.
Error on line 1 of document : The element type "meta" must be terminated by the matching end-tag "". Nested exception: The element type "meta" must be terminated by the matching end-tag "".