PHP Rest API Call with Authorization -



PHP Rest API Call with Authorization -

simple question

where set "authorization: bearer cajwune0fnr78ynj2kz6p8bad"

$service_url = 'https://example.com/something/something.json'; $curl = curl_init($service_url); curl_setopt($curl, curlopt_httpauth, curlauth_basic); curl_setopt($curl, curlopt_userpwd, "username:password"); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_post, true); curl_setopt($curl, curlopt_postfields, $curl_post_data); curl_setopt($curl, curlopt_ssl_verifypeer, false); $curl_response = curl_exec($curl); $response = json_decode($curl_response); curl_close($curl); var_dump($response);

thanks!

you'd set into:

***old

curl_setopt($curl, curlopt_httpheader, 'authorization: bearer cajwune0fnr78ynj2kz6p8bad');

***new

curl_setopt($curl, curlopt_httpheader, array('authorization: bearer cajwune0fnr78ynj2kz6p8bad'));

php api rest authorization

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -