kyleAI_13

cURL

Jul 20th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. function getContents($url) {
  2.     $ch = curl_init();
  3.     $timeout = 5;
  4.     curl_setopt($ch, CURLOPT_URL, $url);
  5.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  6.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  7.     $data = curl_exec($ch);
  8.     curl_close($ch);
  9.     if ($data == FALSE or empty($data)) {
  10.         return false;
  11.     } else return $data;
  12. }
  13.  
  14. $_USER=''; $isLogged = getContents("http://localhost/inc/api/isLogged.api?callback=?");
  15. if (isset($isLogged) && !empty($isLogged)) { $_USER = json_decode($isLogged); }
  16. var_dump($_USER->uname);
Advertisement
Add Comment
Please, Sign In to add comment