Guzzle发布请求在浏览器中工作但不在应用程序中

I am trying to access the wordpress.com API and am having trouble with Guzzle.

$client = new GuzzleHttp\Client();
$request = $client->post('https://public-api.wordpress.com/oauth2/token')
        ->setPostField('client_id', Config::get('wordpress.id'))
        ->setPostField('redirect_uri', Config::get('wordpress.redirect_url'))
        ->setPostField('client_secret', Config::get('wordpress.secret'))
        ->setPostField( 'code', $code)
        ->setPostField('grant_type', 'authorization_code');

If I input all the data into Postman it works! However, the endpoint responds with 400 if I use guzzle. This leads me to believe that the post data is not being sent but having only just started using guzzle I have no idea why. I have checked and all the Config::get... return what they should and so does $code.

Any ideas on what I should be doing?

Update 1

This works with cURL:

    $curl = curl_init( "https://public-api.wordpress.com/oauth2/token" );
    curl_setopt( $curl, CURLOPT_POST, true );
    curl_setopt( $curl, CURLOPT_POSTFIELDS, array(
        'client_id' => Config::get('wordpress.id'),
        'redirect_uri' => Config::get('wordpress.redirect_url'),
        'client_secret' => Config::get('wordpress.secret'),
        'code' => $code, // The code from the previous request
        'grant_type' => 'authorization_code'
    ) );
    curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);
    $auth = curl_exec( $curl );
    $secret = json_decode($auth);
    $access_key = $secret->access_token;
    dd($access_key);

There is someone else having a similar problem to what you describe here. It looks lithe the array method might be a good solution to add those value pairs one at a time?

There seems to be another format option according to the Guzzle docs that might work also declaring it like this:

$request = $client->post('http://httpbin.org/post', array(), array(
    'custom_field' => 'my custom value',
    'file_field'   => '@/path/to/file.xml'
));
$response = $request->send();

Something to try.