Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function GoogleURLShorterner($url)
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, '');
curl_setopt($curlHandle, CURLOPT_HEADER, 0);
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, '{"longUrl":"'.$url.'"}');
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlHandle, CURLOPT_TIMEOUT,30);
curl_setopt($curlHandle, CURLOPT_POST, 1);
$content = curl_exec($curlHandle);
$data = json_decode($content);
return $data->id;
example of use:
echo GoogleURLShorterner($url);
<a href="">article</a>
<a href="">Demo</a>
<a href="">download</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment