PHP Classes
elePHPant
Icontem

SalesNet: Call SalesNet CRM Web services APIs

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2011-12-10 (3 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 286 All time: 6,857 This week: 1,332Up
Version License PHP version Categories  
salesnet 1.0BSD License5.3PHP 5, E-Commerce, Web services
Description Author  

This class can call the SalesNet.com CRM Web services API.

It provides one class that can send SOAP requests to retrieve an authentication token to be able to call other SalesNet Web services APIs.

Another class acts as a proxy to call several SalesNet Web services API using __call to provide virtual functions to those Web service functions.

Currently it supports calling APIs to manage CRM clients, deals, contacts, leads, campaigns, activity, document, company, utility and system.

Picture of Jeremy Cook
Name: Jeremy Cook <contact>
Classes: 2 packages by
Country: Canada Canada
Age: 42
All time rank: 92224 in Canada Canada
Week rank: 321 Up7 in Canada Canada Up

Details provided by the author  
SalesNet PHP Objects
====================

This repository provides two objects to make it a little easier to work with the [SalesNet CRM](http://www.salesnet.com/) SOAP API from within PHP. The first object works with the SalesNet authentication service to retrieve an authentication token while the second is a simple proxy to trap calls to the various SalesNet endpoints and to return the results. Both objects utilise lazy loading so that no requests are sent to SalesNet until they are needed and include full unit tests. 

The Authentication Object
-------------------------

The SalesNet API requires that before any requests are made to the various service endpoints a user must authenticate against the security endpoint. This service returns a token which is valid for up to 12 hours (depending on the settings in the users SalesNet account) and which must be set as a SOAP header in all subsequent requests. The authentication object accepts a company login, username and password. When the doLogin() method is called it will authenticate against the security endpoint and return the token that is returned in a PHP SoapHeader object. Subsequent calls to doLogin() will return the SoapHeader object with the token that has already been retrieved. The user can set the number of hours that the token should be considered valid for, with the default being 12 hours. This object can be serialized and stored in a session or a cache, allowing the security token to be shared across multiple requests.

The SoapProxy Object
--------------------

The SoapProxy object is much simpler than the Authentication object in many ways. It uses PHP's magic __call() method to trap calls to the API, returning the results for the user to process. The SoapProxy object accepts an instance of WebServices\Soap\SalesNet\Authentication which it uses internally to fetch the authentication SoapHeader to successfully call the API. SOAP options can be provided for the PHP SoapClient used in the object.

Example Usage
-------------

The example below illustrates how these classes may be used to call the GetDeals method of the SalesNet deals endpoint. Note that no attempt is made to either guess the arguments needed by the method or to process the return value. For more information on both of these the reader is directed to the SalesNet API documentation.

	<?php
	use WebServices\Soap\SalesNet\Authentication, WebServices\Soap\SalesNet\SoapProxy;
	//Set authentication. This will assume that the token expiry time is 12 hours.
	$auth = new Authentication();
	$auth->setCompanyLogin('YOUR COMPANY LOGIN)
		 ->setUserName('YOUR USERNAME)
		 ->setPassword('YOUR PASSWORD');
	
	$soap = new SoapProxy(SoapProxy::DEALS, $auth);
	$args = array(
		//Setup SOAP method arguments here
	);
	$result = $soap->GetDeals($args);
	?>

For more details please see comments in the code for the classes.
  Files folder image Files  
File Role Description
Files folder imagelibrary (1 directory)
Files folder imagetests (2 files)
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  library  
File Role Description
Files folder imagewebservices (1 directory)

  Files folder image Files  /  library  /  webservices  
File Role Description
Files folder imagesoap (1 directory)

  Files folder image Files  /  library  /  webservices  /  soap  
File Role Description
Files folder imagesalesnet (2 files)

  Files folder image Files  /  library  /  webservices  /  soap  /  salesnet  
File Role Description
  Plain text file authentication.class.php Class Class source
  Plain text file soapproxy.class.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file AuthenticationTest.php Test Unit test script
  Accessible without login Plain text file SoapProxyTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%Total:286All time:6,857
 This week:0This week:1,332Up