infusionsoft / infusionsoft-php

PHP client library for the Infusionsoft API.
https://developer.infusionsoft.com/
Other
130 stars 128 forks source link

DataService query method does not work #70

Closed dctucker closed 8 years ago

dctucker commented 8 years ago

To make a query via the data service I'm having to resort to manually generating a request via the Infusionsoft class instead of relying on the DataService class. Reason being there are non-optional parameters defined in the query method on line 73 of DataService.php which when specified and passed to the request method of the client, returns an XML-RPC error saying "No method matching arguments".

Either this library demands PHP have warnings for unspecified method parameters turned off (not the best practice) or it's just plain broken. Please fix.

mfairch commented 8 years ago

Can you provide a code example of how you got it to throw "no method matching arguments"? You left off the last part of the message.

dctucker commented 8 years ago

Try running:

app('infusionsoft')->data->query('ClientGroup',1000,0,['GroupName'=>'%'],['GroupName','Id']) Get a PHP warning saying "missing argument for DataService::query()"

Try running:

app('infusionsoft')->data->query('ClientGroup',1000,0,['GroupName'=>'%'],['GroupName','Id'],'GroupName','ASC') Get an error:

Infusionsoft\Http\HttpException with message 'exception 'fXmlRpc\Exception\ResponseException' with message 'No method matching arguments: java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer, java.util.HashMap, [Ljava.lang.Object;, java.lang.String, java.lang.String' in /Users/casey/Development/brax-infusion/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/ResponseException.php:32

mfairch commented 8 years ago

Thanks for the example. I am aware that not passing in the last 2 parameters will throw a PHP warning.

The reason you get the error "no method matching arguments" is due to you passing a string instead of a boolean. In the library we can be more specific on what type the parameters are.

Is there a specific reason you wouldn't want to order the data coming back to you?

dctucker commented 8 years ago

Whether or not it's ordered may or may not be important, but the fact that the API samples demonstrate using the method with only five parameters when in fact seven are required, is troubling.

And regarding the last parameter being boolean, the following invocation also fails, probably because the "where" argument is empty...

app('infusionsoft')->data->query('ContactGroup', 1000, 0, [], ['Id','GroupName'],'GroupName',true);

Infusionsoft\Http\HttpException with message 'exception 'fXmlRpc\Exception\ResponseException' with message 'No method matching arguments: java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer, [Ljava.lang.Object;, [Ljava.lang.Object;, java.lang.String, java.lang.Boolean' in /Users/casey/Development/brax-infusion/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/ResponseException.php:32

kressaty commented 8 years ago

Closing, this is covered by #68 which will be the reference issue for the fix.

harshitnayak45 commented 7 years ago

hi @micfai

I have following error when call data service using php api.

Fatal error: Uncaught exception 'fXmlRpc\Exception\FaultException' with message 'Failed to parse XML-RPC request: Unknown type: nil' in /home/linuxbean5455/public_html/amazon/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/FaultException.php:32 Stack trace: #0 /home/linuxbean5455/public_html/amazon/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Parser/XmlReaderParser.php(373): fXmlRpc\Exception\FaultException::fault(Array) #1 /home/linuxbean5455/public_html/amazon/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Client.php(153): fXmlRpc\Parser\XmlReaderParser->parse('<?xml version="...') #2 /home/linuxbean5455/public_html/amazon/Infusionsoft/Http/InfusionsoftSerializer.php(28): fXmlRpc\Client->call('DataService.add', Array) #3 /home/linuxbean5455/public_html/amazon/Infusionsoft/Infusionsoft.php(404): Infusionsoft\Http\InfusionsoftSerializer->request('DataService.add', 'https://api.inf...', Array, Object(Infusionsoft\Http\CurlClient)) #4 /home/linuxbean5455/public_html/amazon/Infusionsoft/Api/DataService.php(14): Infusionsoft\Infusionsoft->request( in /home/linuxbean5455/public_html/amazon/vendor/lstrojny/fxmlrpc/src/fXmlRpc/Exception/FaultException.php on line 32

harshitnayak45 commented 7 years ago

Please let me know the error so i can fix that. I would like to work with data service.

harshitnayak45 commented 7 years ago

I have used this $conID = $infusionsoft->data->add("Contact", $contactData); to add an contact.

bryceleue commented 6 years ago

The data function still appears to be broken. If you are looking for a reference for how to manually build the request like @dctucker mentioned. See Below:

$method='DataService.query';
$table='TableName';
$limit=1000; 
$page=0;
$querydata=array(key' => 'value');
$selectedfields=array('exfield1', 'exfield2');

$contacts = $infusionsoft->request(
          $method,
          $table,
          $limit,
          $page,
          $querydata,
          $selectedfields
);

You can change your method to Whatever you want. For example, @harshitnayak45 above would want 'Dataservice.add' here.