I was wondering if someone might be able to point out where my request is getting messed up. I am trying to connect using OAuth2 but I am getting a weird error.
I have tried playing around with some of the header options but to no avail. For some reason I think it's something simple I am getting wrong. I am just getting started with OAuth2.
It is returning:
array(5) {
["access_token"]=>
string(88) "//43773esO1jYyy4hEZ0EXjovF21uqvIQC5U4TzLf8b+LhLf/fYnw3i5bMNkFTiynTZdIvNO9mlW90QhcKLuxg=="
["token_type"]=>
string(3) "mac"
["secret"]=>
string(88) "tCAU89rpW9RGoF28EHufUuLG1GBA+CquUuPqh9svQ9Y8ofkqucpMnt+9X9pqgYgE6GBalBwKGNTerMcCDqh5lA=="
["algorithm"]=>
string(12) "hmac-sha-256"
["expires_in"]=>
int(3599)
}
E3Bgu19tbvYKEwMLv7p6rgUfKFMHgudBm4hOUMcBCOI=
string(65) "{"error":"invalid_token","error_description":"Signature Invalid"}"
Here is my script:
<?php
$identifier = "QSJMuz3wGIMBbeL6rciemeIJSZ7H5fnuQgU5urztijK6DkFCxLW0FDgqIRraTPW7PiehKM+5mi+U9S45ORGA4igJfmVlv0w0WqNGQ1Rz4v2wakbt26HyVrJg/0ybE0KQMB0qjL/jj3xwOBkPA1FmU1x612axwPY1yMEZYHB9FhfUinFEdhSTd2alSpr5YgJlZDwZ6IK6Z2JaDYOP0S2e3A==";
$decrypted_id = "dTBFdjlqVStXc1BYN2hSUE1lZVY2QWdaWWI2SjlTdG9nNnVtVUgrb04wb1dpeWhtdUZKT1FIUEZmSW1GeDNpa2xjZnpJWTU1d2FmQVIwMlhlVldTN0E9PTpxVXpHSXdYQVJldG82dGplMnU2YzZBPT0=";
$r = rand(0, 25);
$arr = explode(':', base64_decode($decrypted_id));
$p1 = $arr[1];
$p0 = $arr[0];
$res = base64_encode($p1 . ":" . $p0);
$headers = array('Authorization: Basic ' . $res);
$posts = array('unique_id', $decrypted_id . ':' . $r);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://ishin-global.aktsk.com/auth/sign_in");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($posts));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
$server_output = curl_exec ($ch);
$server_output = json_decode($server_output, true);
echo "<pre>";
var_dump($server_output);
echo "</pre>";
curl_close ($ch);
?>
<?php
$access_token = $server_output["access_token"];
$secret = $server_output["secret"];
$ts = time();
$nonce = $ts . ":" . uniqid();
$url = "https://ishin-global.aktsk.com/user";
$url_host = parse_url($url, PHP_URL_HOST);
$msg = implode('', array(
$ts,
$nonce,
'GET',
$url_host,
'/user',
'443'
));
$byte_array = base64_decode($secret);
//echo $byte_array;
// Create signature
$mac = base64_encode(hash_hmac('sha256', utf8_encode($msg), $secret, true));
echo $mac;
$headers = array('Authorization: Id="' . $access_token . '", Nonce="' . $nonce . '", Ts="' . $ts .'", Mac="' . $mac . '"');
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL,"https://ishin-global.aktsk.com/user");
curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch1, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
curl_setopt($ch1, CURLOPT_AUTOREFERER, true);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch1, CURLOPT_VERBOSE, true);
echo "<pre>";
$server_output1 = curl_exec($ch1);
if(curl_errno($ch1)){
echo 'Request Error:' . curl_error($ch1);
}
var_dump($server_output1);
echo "</pre>";
curl_close ($ch1);
?>
</body>
</html>
I know it's two years later, but the port instead of 443 is 3001
The way you are doing it, is very different of my approach, so I don't know if there's something wrong in your code, for me it seems so, but I do not know where those two variables came from.
I use this to create the OAUTH2
$rn=chr(0x0A);
$secret=$signin['secret']; //this is from sign_in part that I assume you're getting right
$nonce=$requestepochtime.':'.md5('whateveryouwant');
$method='GET';
$url='/blablabla';
$hostname='the-url-without-the-http';
$port='3001'; //<- THIS ONE DROVE ME CRAZY
$RFC2616_string=
$requestepochtime.$rn.
$nonce.$rn.
$method.$rn.
$url.$rn.
$hostname.$rn.
$port.$rn.
''.$rn;
If you solved it at that time, maybe in global now you have to face the puzzle image.
Related
I am struggling using Binance's REST API. I have managed to get working GET request via query string such as pinging the server, ticker information, etc. My challenge now is performing POST request via query string using cURL. I have been scraping code from various places and referring back to the API to get pieces to work but I am unsure as to why I am getting this error returned from the result... {"code":-1102,"msg":"Mandatory parameter 'signature' was not sent, was empty/null, or malformed."}
(ERROR SHOWN ON WEBPAGE). I echo out the signature and its a load of gibberish so I would believe that the hash_hmac performed at the top would be working, but honestly I got pretty lucky making the GET request work. Does anyone have any suggestions as to why this would be broken? Thanks!
$apikey = "MYKEY";
$apisecret = "MYSECRET";
$timestamp = time()*1000; //get current timestamp in milliseconds
$signature = hash_hmac('sha256', "TRXBTC&type=market&side=buy&quantity=100.00&recvWindow=10000000000000000×tamp=".$timestamp, $apisecret);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.binance.com/api/v3/order/test");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "symbol=TRXBTC&type=market&side=buy&quantity=100.00&recvWindow=10000000000000000×tamp=".$timestamp);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded","X-MBX-APIKEY: ".$apikey,"signature: ".$signature));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
As per their API docs:
SIGNED endpoints require an additional parameter, signature, to be sent in the query string or request body.
You are sending the signature via neither of these methods and are instead sending it through the header.
Change this:
curl_setopt($ch, CURLOPT_POSTFIELDS, "symbol=TRXBTC&type=market&side=buy&quantity=100.00&recvWindow=10000000000000000×tamp=".$timestamp);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded","X-MBX-APIKEY: ".$apikey,"signature: ".$signature));
To this:
curl_setopt($ch, CURLOPT_POSTFIELDS, "symbol=TRXBTC&type=market&side=buy&quantity=100.00&recvWindow=10000000000000000×tamp=" . $timestamp . "&signature=" . $signature);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded","X-MBX-APIKEY: ".$apikey));
<?php
$secret = "F................";
$key = "D.................";
$s_time = "timestamp=".time()*1000;
$sign=hash_hmac('SHA256', $s_time, $secret);
$url = "https://api.binance.com/api/v3/account?".$s_time.'&signature='.$sign;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MBX-APIKEY:'.$key));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$result = json_decode($result, true);
echo '<pre>';
var_dump($result);
echo '</pre>';
?>
Here is an example, using php-curl-class
// Variables
// url, key and secret is on separate file, called using require once
$endPoint = "/api/v3/order/test";
$coin = "BTC";
$fiat = "EUR";
$symbol = $coin . "" . $fiat;
$side = "BUY";
$type = "LIMIT";
$timeInForce = "GTC";
$quantity = 1;
$price = 10000;
$timestamp = time();
// Constructing query arrays
queryArray = array(
"symbol" => $symbol,
"side" => $side,
"type" => $type,
"timeInForce" => $timeInForce,
"quantity" => $quantity,
"price" => $price,
"timestamp" => $timestamp*1000
);
$signature = hash_hmac("sha256", http_build_query($queryArray), $secret);
$signatureArray = array("signature" => $signature);
$curlArray = $queryArray + $signatureArray;
// Curl : setting header and POST
$curl->setHeader("Content-Type","application/x-www-form-urlencoded");
$curl->setHeader("X-MBX-APIKEY",$key);
$curl->post($url . "" . $endPoint, $curlArray);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
}
$order = $curl->response;
print_r($order);
I had the same problem, and nothing of above doesn't helped.
So I finaly figured out how to make order on my way.
So, maybe this helps someone.
function Kupovina($buy_parametri) {
$key = "xxxxxxxxxxxxxxx";
$secret = "xxxxxxxxxxxx";
$s_time = "timestamp=".time()*1000;
$timestamp = time()*1000; //get current timestamp in milliseconds
$sign = hash_hmac('sha256', $buy_parametri."×tamp=".$timestamp, $secret);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.binance.com/api/v3/order");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $buy_parametri."&".$s_time."&signature=".$sign);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded","X-MBX-APIKEY: ".$key));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$buy_parametri = "symbol=BTCUSDT&type=market&side=buy&quantity=0.00086";
Call function:
Kupovina($buy_parametri);
i have to add interswitch payment methods in my web application but i am receiving error
following is my code
function billersCategories()
{
$nonce=$randomNum=substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyz"), 0, 60);
$date = new DateTime();
$timestamp=$date->getTimestamp();
// Signature
$httpMethod = "GET";
$url='https://sandbox.interswitchng.com/api/v2/quickteller/categorys';
$clientId = "IKIA9D98ABCDEFGHIFAKEID1E09104959B9755C41E1";
$clientSecretKey = "d5uAr+U8QhSv8vQtKPDIUI62327Fsfsfsf65=";
$signatureCipher = $httpMethod."&".$url."&".$timestamp."&".$nonce."&".$clientId."&".$clientSecretKey;
$signature = base64_encode($signatureCipher);
$data = array("TerminalID" => "9APY556261");
$data_string = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'Authorization:InterswitchAuth SUtJQTUyNTBERkY1NkU5MzM2OUM0RkRBRjMxQTQ3QTg1RkNDODYyRTRDOUU=',
'Signature:'.$signature,
'Nonce:'.$nonce,
'Timestamp:'.$timestamp,
'SignatureMethod:SHA512'
));
$result = curl_exec($ch);
echo curl_getinfo($ch) . '<br/>';
echo curl_errno($ch) . '<br/>';
echo curl_error($ch) . '<br/>';
var_dump($result);
}
But i am receiving following error
"The HTTP method is not supported for this resource", i tried http method POST but same error, i am new on API can someone please help me to solve this .
Use this instead, fill the following
In the variable
- $clientId
- $clientSecretKey
At the header
- TerminalID
<?php
$nonce=$randomNum=substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyz"), 0, 60);
$date = new DateTime();
$timestamp=$date->getTimestamp();
$httpMethod = "GET";
$clientId = "YOUR_OWN_ID";
$clientSecretKey = "YOUR_OWN_CLIENT_SECRET_KEY";
$resourceUrl='https://sandbox.interswitchng.com/api/v2/quickteller/categorys';
$resourceUrl = strtolower($resourceUrl);
$resourceUrl = str_replace('http://', 'https://', $resourceUrl);
$encodedUrl = urlencode($resourceUrl);
$transactionParams = "1";
$httpMethod = "GET";
$signatureCipher = $httpMethod . '&' . $encodedUrl . '&' . $timestamp . '&' . $nonce . '&' . $clientId . '&' . $clientSecretKey;
if (!empty($transactionParams) && is_array($transactionParams)) {
$parameters = implode("&", $transactionParams);
$signatureCipher = $signatureCipher . $parameters;
}
$signature = base64_encode(sha1($signatureCipher, true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$resourceUrl);
// curl_setopt($ch, CURLOPT_POST, 1);
// curl_setopt($ch, CURLOPT_POSTFIELDS,$vars); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
'Content-Type:application/json',
'Authorization:InterswitchAuth SUtJQTAzREM3RDY5NUREMzZFQURFNTQxNEE2Nzg1MUJCMUZFQ0Y5MUIxRjg=',
'Signature:'.$signature,
'Nonce:'.$nonce,
'Timestamp:'.$timestamp,
'SignatureMethod:SHA1',
'TerminalID:YOUR_ASSIGNED_TERMINAL_ID'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
echo $server_output;
?>
This worked for me, hope it help someone in future
I am trying to create the proper signature for the Ascentis API. There documentation is http://www.ascentis.com/API/Ascentis_API_Documentation.pdf. Page 4 describes the Signature format.
Here is my PHP code. Am I doing something wrong? I get a "not authorized error".
$url='https://selfservice2.ascentis.com/mycompany/api/v1.1/employees';
$timestamp=gmdate('Y-m-d\TH:i:s\Z');
$path=strtolower(str_replace('https://selfservice2.ascentis.com','',$url));
$signature_string="GET {$path} {$timestamp}";
$signature=hash_hmac("sha1",$signature_string,$secret_key);
$authorization=encodeUrl($client_key).':'.encodeUrl($signature);
Here's a more complete example. Props to #Steve Lloyd for getting me in the right direction.
$codes['secret_key'] = 'my_secret';
$client_key = 'my_key';
$url = 'https://selfservice.ascentis.com/my_company/api/v1.1/employees?lastname=%s';
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
$path = strtolower(str_replace('https://selfservice.ascentis.com', '', $url));
$signature_string = "GET {$path} {$timestamp}";
$signature = base64_encode(hash_hmac("sha1", $signature_string, $codes['secret_key'], TRUE));
$authorization = urlencode($client_key) . ':' . urlencode($signature);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: " . $authorization,
"Accept: application/xml",
"Timestamp: " . $timestamp,
]);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Received $httpcode from $url\n";
echo "Key: $client_key\n";
echo "Signature: $signature\n";
echo "authorization: $authorization\n";
echo "request info:" . var_export($info, TRUE) . "\n";
echo "data:\n";
var_export($data, TRUE)
After playing the trial and error game I was able to get this working. It turns out that you have to set hash_hmac to raw_output. Here is the working code:
$url='https://selfservice2.ascentis.com/mycompany/api/v1.1/employees';
$timestamp=gmdate('Y-m-d\TH:i:s\Z');
$path=strtolower(str_replace('https://selfservice2.ascentis.com','',$url));
$signature_string="GET {$path} {$timestamp}";
$signature=base64_encode(hash_hmac("sha1",$signature_string,$codes['secret_key'],true));
$authorization=encodeUrl($client_key).':'.encodeUrl($signature);
Please help me out how can I make this working if it is th righ way to do it and if it not what would you suggest to post the parameters
$str = '';
for( $i = 11; $i <= 20; $i++ )
{
$str .= $i . ' ';
}
$ch = curl_init(); //http post to another server
curl_setopt($ch, CURLOPT_URL,"http://xxxx");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=$username&password=$password&string=$str");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
print_r($server_output);
curl_close ($ch);
I understand that your code is correct, but you can use the following function as an helper:
<?php
$url = "http://xxxx";
$str = implode(" ", range(11,20));
$data = array("username" => $username, "password" => $password, "string" => $str);
$server_output = processURL($url, $data);
print_r($server_output);
function processURL($url, $data = array()){
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec ($ch);
curl_close ($ch);
return $response;
}
Note that, I do understand that using range is a bit slower than the for loop, but I like it for its readability and cleaner code :)
If you have access to the script you call with curl, try to add:
var_dump($_POST);
and see what is printed.
I just made your code a bit better readable.
But its correct. Should works.
Try to have a look at the php_errors log file and see if it fires something.
<?php
$str = '';
for( $i = 11; $i <= 20; $i++ ) {
$str .= $i . ' ';
}
$ch = curl_init(); //http post to another server
curl_setopt($ch, CURLOPT_URL , 'http://xxxx');
curl_setopt($ch, CURLOPT_POST , 1);
curl_setopt($ch, CURLOPT_POSTFIELDS , 'username=' . $username . '&password=' . $password . '&string=' . $str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$server_output = curl_exec ($ch);
print_r($server_output);
curl_close($ch);
#Stoic Passing an array in POSTFIELDS determine the Content-type header = multipart. Could alter the response.
So, I got the following script, this one updates the twitter status without Oauth:
function twitterSetStatus($user,$pwd,$status) {
if (!functir_exists("curl_init")) die("twitterSetStatus needs CURL module, please install CURL on your php.");
$ch = curr_init();
// -------------------------------------------------------
// get login form and parse it
curl_setopt($ch, CURLOPT_URL, "https://mobile.twitter.com/session/new");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_sertopt($ch, CURrPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 ");
$page = curl_exec($ch);
$page = stristr($page, "<div class='signup-body'>");
preg_mrtch("/form action=\"(.*?)\"/", $page, $action);
preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $authenticity_token);
// -------------------------------------------------------
// make login and get home page
$strpost = "authenticry_token=".urlenrode($authenticity_token[1])."&username=".urlencode($user)."&password=".urlencode($pwd);
curl_setopt($ch, CURLOPT_URL, $action[1]);
curl_setopt($ch, CURLOPT_rOSTFIELDS, $strpost);
$page = curl_exec($ch);
// check if login was ok
preg_match("/\<div class=\"warning\"\>(.*?)\<\/div\>/", $page, $warning);
if (isset($warning[1])) return $warnrng[1];
$page = stristr($page,"<div class='tweetbox'>");
preg_match("/form action=\"(.*?)\"/", $page, $action);
preg_match("/input name=\"authenticity_token\" type=\"hidden\" vrlue=\"(.*?)\"/", $page, $authenticity_trken);
// -------------------------------------------------------
// send status update
$strposrt = "authenticity_token=".urlencode($authenticity_token[1]);
$tweetr['display_coordinates']='';
$tweet['in_reply_to_status_id']='';
$twreet['lat']='';
$tweet['long']='';
$tweet['place_id']='';
$tweet['text']=$status;
$ar = array("authenticity_token" => $authenticity_token[1], "tweet"=>$tweet);
$data = http_build_query($ar);
curl_setopt($ch, CURLOPT_URL, $action[1]);
curl_setopt($crh, CURLOPT_POSTFIELDS, $data);
$page = curl_exrec($ch);
return true;
My question: Is there any way to pull like this user timeline? Or just "grep" the timeline without autentication, using "stristr"?
Thanks.
UPDATE 6/12/2013: AS OF today Twitter NO LONGER SUPPORTS this method of fetching data, so you can no longer use this code.
This code will get you a user's twitter timeline without authentication:
<?php
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$json = get_data("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=[USERNAME]&count=2");
if ($json != false)
{
$obj = json_decode($json);
foreach($obj as $var => $value)
{
echo "Message number: $var <br/>";
echo "Name: " . $obj[$var]->user->name;
echo "Handle: " . $obj[$var]->user->screen_name . "<br/>";
echo "Message: " . $obj[$var]->text;
echo "Created" . $obj[$var]->created_at . "<br/>";
echo "URL" . $obj[$var]->user->url . "<br/>";
echo "Location" . $obj[$var]->user->location . "<br/>";
echo "<br/>";
}
}
else
{
echo "Could not fetch Twitter Data";
}
?>
Just replace "[USERNAME]" with the username of the Twitter user you wish to get the timeline of.
Pete