(PHP) Correct way to send GET /orders using GuzzleHttp

I’m getting 401 Unauthorized error when using the below code to get list of last 100 orders. I’m able to get the orders using curl from command line, and have verified that $token contains the right access token. I suppose it’s not getting passed correctly:

$token = 'abcd1234567890'; 
$requestBody = array('access_token' => $token);
$url = 'https://api.infusionsoft.com/crm/rest/v1/orders?limit=1&offset=100&order_by=id';
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', $url, array(
    'form_params' => $requestBody
));

$response = (string) $response->getBody();

Some help will be greatly appreciated.

Put access_token in the url not the request body

2 Likes

Ah, very nice, very nice! Thanks a lot. :slight_smile: