Advertisement
djmp

Untitled

Feb 27th, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.     $url='http://oreno.imouto.org/post/index.json?limit=20&tags=hatsune_miku';
  3.     $data = get_data($url);
  4.     $obj = json_decode($data);
  5.     /* gets the data from a URL */
  6.  
  7.     function get_data($url)
  8.     {
  9.     $ch = curl_init();
  10.     $timeout = 5;
  11.     curl_setopt($ch,CURLOPT_URL,$url);
  12.     curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  13.     curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  14.     $data = curl_exec($ch);
  15.     curl_close($ch);
  16.     return $data;
  17.     }
  18.    
  19.     $json = json_encode($data);
  20.  
  21.     $callback = $_GET['callback'];
  22.     echo $callback.'('. $json . ')';   
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement