Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. // This is the URL you want to shorten
  3. $longUrl = 'https://es.search.yahoo.com/search?fr=mcafee&type=C214ES662D20160407&p=w3c';
  4. $customn = '';
  5.  
  6.  
  7. // Get cURL resource
  8. $curl = curl_init();
  9. // Set some options - we are passing in a useragent too here
  10. curl_setopt_array($curl, array(
  11. CURLOPT_RETURNTRANSFER => 1,
  12. CURLOPT_URL => 'https://keep.re/ajax/shorten_api.php?url='.urlencode($longUrl).'&custom='.urlencode($custom),
  13. 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')
  14. ));
  15. // Send the request & save response to $resp
  16. $resp = curl_exec($curl);
  17. // Close request to clear up some resources
  18. curl_close($curl);
  19.  
  20.  
  21. $response = $resp;
  22.  
  23. // Change the response json string to object
  24. $json = json_decode($response);
  25.  
  26. echo 'Shortened URL is: '.$json;
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement