Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass "--user test:test" in curl options in php #31

Closed
Fshamri opened this issue Sep 16, 2017 · 2 comments
Closed

How to pass "--user test:test" in curl options in php #31

Fshamri opened this issue Sep 16, 2017 · 2 comments

Comments

@Fshamri
Copy link

Fshamri commented Sep 16, 2017

I know this is not a bug, but really seek your help. i am trying to call this api to generate token. so i wrote php function to perform the call. something like:

ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch); 

but i get authentication failed. this i think because the user/pass should be passed in the form of:
--user test:test.
can you please help

@tuupola
Copy link
Owner

tuupola commented Sep 18, 2017

Above code looks correct, problem is in somewhere else. I would start debugging it with something like:

  1. Are you calling the correct $url?
  2. Double check you have correct $username and $password
  3. Can you make the same request with commandline curl?
  4. Do you have some other authentication middlewares?
  5. What is output of print_r($info)?

etc

@tuupola
Copy link
Owner

tuupola commented Nov 8, 2017

No feedback, closing.

@tuupola tuupola closed this as completed Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants