Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. $a='stringsearch';
  2. $username = 'username';
  3. $password = 'password';
  4. $url = "http://exemplo.meuwebservice:(porta)/paraexemplo/$a";
  5.  
  6. $ch = curl_init($url);
  7. curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  8. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  9.  
  10. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
  12. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  13. curl_setopt($ch, CURLOPT_HTTPHEADER, "Accept: application/json" );
  14.  
  15.  
  16. $output = curl_exec($ch);
  17. $info = curl_getinfo($ch);
  18.  
  19.  
  20. curl_close($ch);
  21.  
  22. $obj = json_decode($output);
  23. $json_output = json_decode($output, true);
  24.  
  25. foreach($json_output as $item){
  26. foreach($item as $dados){
  27. echo $dados;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement