Error Connecting to API

Hi
I am currently trying to setup some script whereby I can query the OrderItem table using a conact id and pull back order information for a given contact.

I am using php SDK setup with composer etc…

I have hit a bit of an issue that i can’t seem to resolve - I am stuck with teh following error but not sure what to do to resolve it:

Fatal error: Uncaught exception ‘Infusionsoft\Http\HttpException’ with message 'exception ‘fXmlRpc\Exception\ResponseException’ with message ‘No method matching arguments: java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.HashMap, [Ljava.lang.Object;, java.lang.String, java.lang.Boolean’ in /var/www/vhosts/XXXXXXXX.co.uk/site1/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/ResponseException.php:33 Stack trace: #0 /var/www/vhosts/XXXXXXXX.co.uk/site1/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Client.php(162): fXmlRpc\Exception\ResponseException::fault(Array) #1 /var/www/vhosts/XXXXXXXX.co.uk/site1/vendor/infusionsoft/php-sdk/src/Infusionsoft/Http/InfusionsoftSerializer.php(28): fXmlRpc\Client->call(‘DataService.que…’, Array) #2 /var/www/vhosts/XXXXXXXX.co.uk/site1/vendor/infusionsoft/php-sdk/src/Infusionsoft/Infusionsoft.php(384): Infusionsoft\Http\InfusionsoftSerializer->request(‘https://api.inf…’, ‘DataService.que…’, Array, Object(Infusionsoft\Http\GuzzleClient)) #3 /var/www/vhos in /var/www/vhosts/XXXXXXXX.co.uk/site1/vendor/infusionsoft/php-sdk/src/Infusionsoft/Http/InfusionsoftSerializer.php on line 34

Does anyone have any ideas on how to resolve this?

Kind Regards

Would you be able to provide the code snippet that is performing that call? It’s likely that a parameter is just incorrect on the call.

Hi Tom

Apologies, should have included that in the first place - please see the following:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
date_default_timezone_set("America/New_York");

session_start();


// Require vendor and InfSoft SDK
require_once 'vendor/autoload.php';

// InfSoft client ID and secret key
$infusionsoft = new \Infusionsoft\Infusionsoft(array(
	'clientId'     => ‘xxxxxxxxxxxxxxxxx’, 
	'clientSecret' => 'xxxxxxxxxxxxxxxxx', 
	'redirectUri'  => 'http://www.example.com',
));

// If the serialized token is available in the session storage, we tell the SDK
// to use that token for subsequent requests.
if (isset($_SESSION['token'])) {
	$infusionsoft->setToken(unserialize($_SESSION['token']));
}

// If we are returning from Infusionsoft we need to exchange the code for an
// access token.
if (isset($_GET['code']) and !$infusionsoft->getToken()) {
	$_SESSION['token'] = serialize($infusionsoft->requestAccessToken($_GET['code']));
	//$infusionsoft->requestAccessToken($_GET['code']);
}

if ($infusionsoft->getToken()) {
	// Save the serialized token to the current session for subsequent requests
	$_SESSION['token'] = serialize($infusionsoft->getToken());

	// MAKE INFUSIONSOFT REQUEST
} else {
	echo '<a href="' . $infusionsoft->getAuthorizationUrl() . '">Click here to authorize</a>';
}


// Uncomment the below to manually run teh authorisation process to get token
//echo '<a href="' . $infusionsoft->getAuthorizationUrl() . '">Click here to authorize</a>';

//echo '<br /><br />';	


$table = 'OrderItem' ;
$limit = '1000' ;
$page = '0' ;
$queryData = array('Id' => '33249'); //WAS ~>=~33249
$selectedFields = array('Id') ; //Set further fields for more data
$orderBy = 'Id';

$test33 = $infusionsoft->data()->query($table, $limit, $page, $queryData, $selectedFields, $orderBy, true) ;

var_dump($test33);
$limit = '1000' ;
$page = '0' ;

should be

$limit = 1000 ;
$page = 0 ;

Hi Tom

Many thanks for that, I now have a returned array but it’s empty. Am I querying the correct fields do you know?

The results for the query for that particular contact id should be around 60 results

KInd Regards

Hi @James_Gardner,

Change the data type as you did with the others, for the query on the id to integer or at least, you should be able to get away in PHP with just typecasting it using (int)

Hi

Many thanks - I have changed the id query to an integer but unfortunately I’m still getting a zero result. Any ideas what else may be up?

Kind Regards

Hi

Does anyone know where I’m going wrong at all?

Kind Regards

Try changing your query to ‘Id’=>‘%’ and see if you can’t get a page of just “anything” first

Hi John

Many thanks, yes got to the bottom of it now I think and can now pull back results

many thanks for your help

Kind Regards

2 Likes