Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. $service_url = 'https://example.com/something/something.json';
  2. $curl = curl_init($service_url);
  3. curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  4. curl_setopt($curl, CURLOPT_USERPWD, "username:password"); //Your credentials goes here
  5. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  6. curl_setopt($curl, CURLOPT_POST, true);
  7. curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
  8. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //IMP if the url has https and you don't want to verify source certificate
  9.  
  10. $curl_response = curl_exec($curl);
  11. $response = json_decode($curl_response);
  12. curl_close($curl);
  13.  
  14. var_dump($response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement