Hello! Based on previous posts here and some web research I have been
trying to get a "lookup number of clicks" function to work in PHP (A
language I do not yet really "speak").
Any debugging help would be appreciated.
Thanks!
DwenD...@gmail.com
<?php
function get_bitly_clicks($shorturl) {
$bitly1 = "
http://api.bit.ly/v3/clicks?shortUrl=";
$bitly1b = urlencode($shorturl);
$bitly2 = "&login=mybitlyname&apiKey=mybitlykey";
$bitly3 = "&format=json";
$url = $bitly1.$bitly1b.$bitly2.$bitly3;echo($shorturl);
//using curl
$curlObject = curl_init($url);
//curl_setopt($curlObject,CURLOPT_URL,$url);
curl_setopt($curlObject,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curlObject,CURLOPT_HEADER,false);
$result_json = curl_exec($curlObject);
curl_close($curlObject);
echo($result_json);
//decode JSON. Assumes that it is PHP5
$result = json_decode($result_json);
//return $result->results['user_clicks']; // This is where
I'm lost on the syntax the rest
return $result->{'data'}->{'clicks'}->{'user_clicks'}; //
seems to work just fine.
//return $result['data'][clicks][user_clicks];
}
$gotit = get_bitly_clicks('
http://bit.ly/shorturl_to_check');
echo($gotit);
?>