Coming soon - Get a detailed view of why an account is flagged as spam!
view details
2
How to troubleshoot my basic Authorization access attempt to this api?
Post Body

I'm attempting to connect to an API in PHP. I've been given connection details (all in $api_headers) however I'm struggling to gain access and I'm not sure what I'm missing when trying to pass my basic authorization key.

I'd specifically like to know more about how my current request is being sent/received by the server. I know that the authorization key is base64_encoded, not sure if I'm meant to decode before sending it over?

My knowledge of http is limited, and I've been struggling to ask the right questions in my search to find an answer.

My code is here:

<?php

$ch = curl_init();

$api_headers = array(
    'Accept­Tenant: uk',
    'Accept­Language: en-GB',
    'Authorization: Basic VGVjaFRlc3RBUEk6dXNlcjI=',
    'Host: hostname.com',
    );

$url = "http://urlhere.com";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $api_headers);

$data = curl_exec($ch);

curl_close($ch);

//test the url connection
if (!$fp = fopen($url, 'r')) {
    trigger_error("Unable to open URL ($url)", E_USER_ERROR);
}

$meta = stream_get_meta_data($fp);

print_r($meta);

fclose($fp);
?>

Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
14,533
Link Karma
10,604
Comment Karma
3,929
Profile updated: 2 days ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago