I need to integrate an API so I write function:
public function test() {
$client = new GuzzleHttp\\Client();
try {
$res = $client->post(\'http://ex
The problem is that in Postman you're sending the data as a form, but in Guzzle you're passing the data in the 'json'
key of the options array.
I bet that if you would switch the 'json'
to 'form_params'
you would get the result you're looking for.
$res = $client->post('http://example.co.uk/auth/token', [
'form_params' => [
'client_id' => 'SOMEID',
'client_secret' => '9999jjjj67Y0LBLq8CbftgfdreehYEI=',
'grant_type' => 'client_credentials'
]
]);
Here's a link to the docs in question: http://docs.guzzlephp.org/en/stable/quickstart.html#sending-form-fields
Also, I noticed a typo - you have cliend_id
instead of client_id
.