Retrieve Code

I am trying to create a code that will retrieve leads data from our customer management software. Here is my entire code, minus the encryption key, I have highlighted the specific part I am working on. I am new to PHP so any help I could get would be awesome, or if you need any other questions answered then let me know.


#!/usr/bin/env php
<?php

// Configuration:
$apiKey   = 'AUTH KEY';
$username = 'AUTH USERNAME';
// End of configuration

require_once('../NutshellApi.php');
$api = new NutshellApi($username, $apiKey);

/**
 * Example: Retrieving entities from the Nutshell API using find* and get* methods
 * 
 * Relevant documentation:
 * http://www.nutshell.com/api/retrieving-editing.html
 * http://www.nutshell.com/api/finding-searching.html
 */

// Retrieve a contact
/**echo "getContact example\n------------------------------------------------\n";
$params = array( 'contactId' => 5259 );
$result = $api->call('getContact', $params);
var_dump($result);

// Find contacts attached to lead #1209
echo "\nfindContacts example\n------------------------------------------------\n";
$params = array(
		'query' => array(
			'leadId' => 2926,
		),
);
$result = $api->findContacts($params);
var_dump($result); 

echo "searchLeads example\n------------------------------------------------\n"; 
$params = searchLeads	($status = 0,
 	$limit = 40 
)	
    
 
findLeads ($query,
 	$orderBy = '2926',
 	$orderDirection = 'ASC',
 	$limit = 50,
 	$page = 1,
 	$stubResponses = true 
);	
$result = $api->findLeads($params);
var_dump($result);

   **/

$params = array(
    'findLeads' => array('Status' =>0),
);

Well, nothing was “highlighted”, did you mean commented-out? So, you have a system that pulls leads that are
attached to a contact id and uses it to locate leads for that contact. Un-comment the code and tell us where it
is failing for you. Tell us what line is failing and we might be able to help.

$params at the bottom of the code. I added code tags, and the highlighting fails at that point.

Here is the direct portion of code that I am working with. The commented out code is just code that came in the example I am using.

echo “searchLeads example\n------------------------------------------------\n”;
$params = searchLeads ($status = 0,
$limit = 40
)

findLeads ($query,
$orderBy = ‘2926’,
$orderDirection = ‘ASC’,
$limit = 50,
$page = 1,
$stubResponses = true
);
$result = $api->findLeads($params);
var_dump($result);

**/

$params = array(
‘findLeads’ => array(‘Status’ =>0),
);

Although, I have tried multiple ways, and kind of got lost in what I was doing. There may be code that isn’t necessary anymore. Here is a link to the entire file.

https://www.dropbox.com/sh/roxv6s8vdg69y2d/AACs9EcSkmk35p2p0SEEzf4Ha?dl=0

I am working on the retrieve.php file in PHP/Mars/Examples/retrieve.php

Well, your code version:

$params = searchLeads ($status = 0, $limit = 40 )
does not have an ending " ; " and it does not conform at all to the needed layout of the original:
$params = array( 'query' => array( 'leadId' => 2926, ), );
As you see, yours just has a couple of variables stuck into it and the correct layout has an "object" embedded into it. (In the form of an array called 'query') Therefore, your code will never work. Fix up your $params array and you should be all set.
Sponsor our Newsletter | Privacy Policy | Terms of Service