Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doing "curl -u" with Guzzle

Tags:

php

guzzle

I'm working with a service that requires me to call it via:

curl -u username:password -X POST "http://www.theirurl.com"

I'd like to use Guzzle rather than do a raw CURL, however. Is there a way to have Guzzle pass the -u parameter? I tried User-Agent, but that's not correct.

like image 923
Anthony Avatar asked Mar 13 '15 15:03

Anthony


1 Answers

That's not a user agent, that's HTTP Basic Authentication.

$client->post('http://www.theirurl.com/', ['auth' => ['username', 'password']]);

http://guzzle.readthedocs.org/en/latest/request-options.html?highlight=auth#auth

like image 167
ceejayoz Avatar answered Sep 22 '22 19:09

ceejayoz