Hi Guys,
I'm having trouble getting issues from my account when doing Base 64 encoding for Authorization, is there a way to do this with curl within PHP?
Here's my code:
<?php $username = 'testclient'; $password = 'test@123'; $url = "https://xxxxxx.atlassian.net/rest/api/2/project"; $ch = curl_init(); $headers = array( 'Accept: application/json', 'Content-Type: application/json' ); $test = "This is the content of the custom field."; curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); //curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); $result = curl_exec($ch); $ch_error = curl_error($ch); if ($ch_error) { echo "cURL Error: $ch_error"; } else { echo $result; } curl_close($ch); ?>
If I leave the code as is, it works. However, if I change my username and password to a Base64 string and replace it with something like:
$base64string = 'asdlfkjadslfjasdflkdasf' ... curl_setopt($ch, CURLOPT_USERPWD, $base64string);
it doenst work :(
What am I doing incorrectly?
Thanks!
Community moderators have prevented the ability to post new answers.
You can try to set the headers manually, see : http://www.php.net/manual/en/function.curl-setopt.php#80271
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.