Php confluence api


iam using rest api to get spaces list from confluence using php curl . But iam getting the error .please check my code


$url = "";
$ch = curl_init();
$headers = array(
    'Accept: application/json',
    'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxx'        // this is the oauth token
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_URL, $url);
$result = curl_exec($ch);
$ch_error = curl_error($ch);
if ($ch_error) {
    echo "cURL Error: $ch_error";
} else {
    echo $result;


Response is {"error": "Failed to parse Connect Session Auth Token"}

1 answer

This widget could not be displayed.

The token is incorrect, you'll need to fix that.  It's the Authorisation line, but I can't tell you what's wrong with it as I don't know what php does with it exactly.

Replaced my original token with xxxxxx for security purpose . Can you please show me the example on how to use authorisation line ?

I am sorry, I was not clear.  I had assumed the xxx were obscuring the actual data.  What I'm trying to say is that there is something wrong with the token in there.  I can't tell you whether it's a bad token because I don't know how you've generated, or if it is something php is doing with it that makes it broken for Confluence.

Hi Sampath, if you have fixes for this issue... Please share... I am also facing the same problem...

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

504 views 7 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you