0

I am using curl in the terminal to access and request a JSON file. It should respond with a JSON file.

curl --basic --user email : password "http:/www.appannie.com/v1/accounts/acntnum/..."

What is its equivalent in PHP curl?

I have used:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERPWD, $email.".".$password);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    $response = curl_exec($ch);
    $info = curl_getinfo($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    curl_close($ch);
     
    return $response;

But it fails.

My reference is this: http://support.appannie.com/categories/20082753-Analytics-API

1 Answer 1

1

I believe the USER PASSWORD needs to be separated by ':'

 curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password);
Sign up to request clarification or add additional context in comments.

2 Comments

Somehow i cant see the exact error. But when i used var_dump($response), It will print bool(false). That's why i think the curl failed. I dont why my browser dont show the error.
I have another link to my question which i created earlier than this : stackoverflow.com/questions/17710671/…

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.