i am trying to use an api of url shorter to shorten my wp urls..but i am getting "Parse error: syntax error, unexpected T_STRING" and this is my code..if someone can help me function isup() { //login information $url = get_permalink(); //for wordpress permalink $format = 'json'; //choose between json or xml //generate the URL $isup = 'http://isup.in/api/new.json?url='.urlencode($url).'; //fetch url $response = file_get_contents($isup); //for json formating if(strtolower($format) == 'json') { $json = @json_decode($response,true); echo $json['results'][$url]['shortUrl']; } else //for xml formatting { $xml = simplexml_load_string($response); echo 'http://isup.in/'.$xml->results->nodeKeyVal->hash; } } PHP:
What line does it say the error is, my guess is this should work: function isup() { //login information $url = get_permalink(); //for permalink $format = 'json'; //choose between json or xml //generate the URL $isup = 'http://isup.in/api/new.json?url='.urlencode($url); //fetch url $response = file_get_contents($isup); //for json formating if(strtolower($format) == 'json') { $json = @json_decode($response,true); echo $json['results'][$url]['shortUrl']; } else //for xml formatting { $xml = simplexml_load_string($response); echo 'http://isup.in/'.$xml->results->nodeKeyVal->hash; } } PHP:
Yea, the problem was this line: $isup = 'http://isup.in/api/new.json?url='.urlencode($url).'; Code (markup): at the end of the line you append an open quote to the string, but then never close it. As you aren't appending any content, the period and single tick quote can both be removed, leaving: $isup = 'http://isup.in/api/new.json?url='.urlencode($url); Code (markup):