Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. $host = "10.100.2.7/portalwsServer/pns/";
  2. $port = 80;
  3. $username = "wsadmin";
  4. $password = "p0rt4lws4dm1n";
  5. $nip = $_POST['nip'];
  6. $process = curl_init($host.$nip);
  7. curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  8. curl_setopt($process, CURLOPT_HEADER, 0);
  9. curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
  10. curl_setopt($process, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
  12. $return = curl_exec($process);
  13. curl_close($process);
  14.  
  15. if (strpos($return,'HTTP Status 404') !== false) {
  16. $msg['result'] = -1;
  17. $msg['message'] = 'Error 404 from server';
  18. echo json_encode($msg);
  19. } else {
  20. $pns = json_decode($return);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement