/ Published in: PHP
URL: http://href.in/api_example.php
To use href.in API to generate a short URL. using php curl
Expand |
Embed | Plain Text
//gets the data from a URL function get_tiny_url($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,'http://href.in/api.php?create='.$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } //test it out! $new_url = get_tiny_url('http://twitter.com/inerds'); //returns http://href.in/gh7uab echo $new_url
You need to login to post a comment.
