PHP examples

Discussion in 'PHP' started by gilbertsavier, Aug 17, 2009.

  1. #1
    Hello,

    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('/<ns1:(\w+)/', '<$1 xmlns="'.$this->namespace.'"', $request, 1);
    $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
    $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$this->namespace.'"'), array('/', ''), $request);

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

    }

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

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

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

    $customerArray = array(
    "CustomerID"=>"",
    "Code"=>"",
    "Name"=>"$name",
    "Contact"=>"",
    "Telephone"=>"",
    "Mobile"=>"",
    "Fax"=>"",
    "Email"=>"$email",
    "Address1"=>"$address",
    "Address2"=>"",
    "Address3"=>"$town",
    "Address4"=>"$country",
    "Postcode"=>"$postcode",
    "Website"=>"",
    "EC"=>"0",
    "Notes"=>"",
    "Source"=>"",
    "Discount"=>"0",
    "ShowDiscount"=>"0",
    "PaymentTerms"=>"0",
    "ExtraText1"=>"1",
    "ExtraText2"=>"1",
    "CheckBox1"=>"1",
    "CheckBox2"=>"1",
    "Created"=>"$today",
    "Updated"=>"$today");

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

    }
    else
    {
    $id = $oResponse->InsertCustomerResult;

    $return = $id;

    }
    return $return;
    }

    -----------------------------
    Thanks & regards
    Lokananth
    <a href="http://www.mioot.com" >Live Chat Software</a>
     
    gilbertsavier, Aug 17, 2009 IP
  2. Alice24

    Alice24 Greenhorn

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    try to put it in the php tags or code to exclude the faces. :)
     
    Alice24, Aug 17, 2009 IP
  3. pubdomainshost.com

    pubdomainshost.com Peon

    Messages:
    1,277
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What is the purpose of this code? where have you deployed them and why should one use them? Can you give examples and utility of the code posted?

    Also use Code Tags to avoid frowns and smiley's
     
    pubdomainshost.com, Aug 17, 2009 IP