PDA

View Full Version : PHP examples



gilbertsavier
08-06-2009, 03:28 AM
These are working for me, feel free to use them at your own risk

class MSSoapClient extends SoapClient {
private $namespace;
function __doRequest($request, $location, $action, $version) {


$request = preg_replace('/<ns*:(\w+)/', '<$* xmlns="'.$this->namespace.'"', $request, *);
$request = preg_replace('/<ns*:(\w+)/', '<$*', $request);
$request = str_replace(array('/ns*:', 'xmlns:ns*="'.$this->namespace.'"'), array('/', ''), $request);

// parent call
return parent::__doRequest($request, $location, $action, $version);
}
function setNamespace($sNamespace)
{
$this->namespace=$sNamespace;
}

}

To make a new ******** - I'm only you can extend the function to add other details to the record.

function newKashflow********($soapClient,$idAccount,$name,$address,$town,$postcode,$country,$email)
{
//returns ******** id if ok else 0

$today = date("Y-m-d",mktime());

$********Array = array(
"********ID"=>"",
"Code"=>"",
"Name"=>"$name",
"Contact"=>"",
"Telephone"=>"",
"Mobile"=>"",
"Fax"=>"",
"Email"=>"$email",
"Address*"=>"$address",
"Address2"=>"",
"Address*"=>"$town",
"Address4"=>"$country",
"Postcode"=>"$postcode",
"Website"=>"",
"EC"=>"0",
"Notes"=>"",
"Source"=>"",
"Discount"=>"0",
"ShowDiscount"=>"0",
"PaymentTerms"=>"0",
"ExtraText*"=>"*",
"ExtraText2"=>"*",
"CheckBox*"=>"*",
"CheckBox2"=>"*",
"Created"=>"$today",
"Updated"=>"$today");

$args = array ("UserName"=>"your username here", "Password"=>"your password here","custr"=>$********Array);
$oResponse = $soapClient->Insert********($args);
//handle any errors
if($oResponse->Status != "OK")
{
echo $oResponse->StatusDetail;
$return = 0;

}
else
{
$id = $oResponse->Insert********Result;

$return = $id;

}
return $return;
}