0

Simple question

Where would I put "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!

1 Answer 1

2

You'd put it into:

***old

curl_setopt($curl, CURLOPT_HTTPHEADER, 'Authorization: Bearer cajwune0fnr78ynj2kz6p8bad');

***new

curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Bearer cajwune0fnr78ynj2kz6p8bad'));
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Its giving me this error, apparently its not liking the string. Any ideas? Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE arguments in /web/com/140330164410217/main.php on line 9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.