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

(Ankush Thakur) #1

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.

(John Borelli) #2

Put access_token in the url not the request body

(Ankush Thakur) #3

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