difference retrieve information curl and Guzzle

144 views
Skip to first unread message

Tanguy Bernard

unread,
Jul 22, 2015, 6:36:50 AM7/22/15
to Guzzle - PHP HTTP client and REST client framework
Hello,
I try to get information about my gitlab session, and the response between guzzle and curl in completely different :


curl -X POST "https://git.my_site.com/api/v3/session?login=my_user&password=my_password"
{
  "id": 1,
  "username": "john_smith",
  "email": "jo...@example.com",
  "name": "John Smith",
  "private_token": "dd34asd13as",
  "blocked": false,
  "created_at": "2012-05-23T08:00:58Z",
  "bio": null,
  "skype": "",
  "linkedin": "",
  "twitter": "",
  "website_url": "",
  "dark_scheme": false,
  "theme_id": 1,
  "is_admin": false,
  "can_create_group": true,
  "can_create_team": true,
  "can_create_project": true
}

And in Guzzle :
$request = $client->createRequest('POST',
'https://git.my_site.com/api/v3/session', ['query' => $data, "debug" => true] );
$res= $client->send($request);


object(GuzzleHttp\Message\Response)[563] private 'reasonPhrase' => string 'Created' (length=7) private 'statusCode' => int 201 private 'effectiveUrl' => string 'https://git.my_site.com/api/v3/session?login=my_user&password=my_password' (length=76) private 'headers' (GuzzleHttp\Message\AbstractMessage) => array (size=9) 'date' => array (size=1) 0 => string 'Wed, 22 Jul 2015 10:22:43 GMT' (length=29) 'status' => array (size=1) 0 => string '201 Created' (length=11) 'content-type' => array (size=1) 0 => string 'application/json' (length=16) 'content-length' => array (size=1) 0 => string '465' (length=3) 'x-runtime' => array (size=1) 0 => string '0.049605' (length=8) private 'headerNames' (GuzzleHttp\Message\AbstractMessage) => array (size=9) 'date' => string 'Date' (length=4) 'server' => string 'Server' (length=6) 'status' => string 'Status' (length=6) 'content-type' => string 'Content-Type' (length=12) 'content-length' => string 'Content-Length' (length=14) 'etag' => string 'ETag' (length=4) 'cache-control' => string 'Cache-Control' (length=13) 'x-request-id' => string 'X-Request-Id' (length=12) 'x-runtime' => string 'X-Runtime' (length=9) private 'body' (GuzzleHttp\Message\AbstractMessage) => object(GuzzleHttp\Stream\Stream)[540] private 'stream' => resource(627, stream) private 'size' => null private 'seekable' => boolean true private 'readable' => boolean true private 'writable' => boolean true private 'uri' => string 'php://temp' (length=10) private 'customMetadata' => array (size=0) empty private 'protocolVersion' (GuzzleHttp\Message\AbstractMessage) => string '1.1' (length=3)

But I want the Curl information. How can I do this with Guzzle ?

Thanks in advance.

Tanguy

Reply all
Reply to author
Forward
0 new messages