Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // This is the URL you want to shorten
- $longUrl = 'https://es.search.yahoo.com/search?fr=mcafee&type=C214ES662D20160407&p=w3c';
- $customn = '';
- // Get cURL resource
- $curl = curl_init();
- // Set some options - we are passing in a useragent too here
- curl_setopt_array($curl, array(
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'https://keep.re/ajax/shorten_api.php?url='.urlencode($longUrl).'&custom='.urlencode($custom),
- curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13')
- ));
- // Send the request & save response to $resp
- $resp = curl_exec($curl);
- // Close request to clear up some resources
- curl_close($curl);
- $response = $resp;
- // Change the response json string to object
- $json = json_decode($response);
- echo 'Shortened URL is: '.$json;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement