New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: HtmlPhp

縮.jp api for tweetie

70 Views
Copy Code Show/Hide Line Numbers
   1:  <?php
   2:  $ch = curl_init();
   3:  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   4:  //the url of api
   5:  $url="http://api.xn--jj0a.jp/generate.json";
   6:  curl_setopt($ch, CURLOPT_URL, $url);
   7:  //I dont know why but I have to set the agent or it will return 403
   8:  $useragent="Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-US) AppleWebKit/532.6 (KHTML, like Gecko) Chrome/4.0.267.0 Safari/532.6";
   9:  curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  10:  //the query , for more detail: http://jamadam.com/blog/?b=3557
  11:  $query="fUrl=".$_GET['url'];
  12:  curl_setopt($ch, CURLOPT_POST, true);
  13:  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
  14:  $json = curl_exec($ch);
  15:   
  16:  $result=json_decode($json,true);
  17:  echo $result['result']['generated'];
  18:  ?>
by b123400
  January 31, 2010 @ 11:59am

Add a comment


Report Abuse
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate