0 Replies Latest reply on Feb 27, 2013 8:29 AM by 993617

    How to use This webservice in PHP ?

    993617
      Hello.

      I'm trying to use this webservice in PHP but there isn't a documentation or something that can help me.

      I have this function, and she returns to me a sessionID :

      function wslogin() {
           global $crmdomain;
           $url = $crmdomain . "/Services/Integration?command=login";
           $page = "/Services/Integration?command=login";
           $headers = array(
           "GET ".$page." HTTP/1.0",
           "UserName: *****",
           "Password: *****",
           );
           $ch = curl_init();
           curl_setopt($ch, CURLOPT_URL,$url);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
           curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
           curl_setopt($ch, CURLOPT_HEADER, true);
           $data = curl_exec($ch);
           if (!curl_errno($ch)) {
                // Show me the result
                $sessionid = substr($data,(strpos($data,"Set-Cookie:")+23),(strpos($data,";")-strpos($data,"Set-Cookie:")-23));
                curl_close($ch);
                
                return $sessionid;
           }
      }

      Now, i want to retrieve for example an user... i need to get an user, set an user (insert or update), check if a user exist or not...

      I have test this :

      function getContactInfo ($contactid,$sessionid) {
           global $crmdomain;
           $serverpath = $crmdomain . "/Services/Integration;jsessionid=$sessionid";
           $namespace= "urn:crmondemand/ws/contact/10/2004";
           $soapaction = "document/urn:crmondemand/ws/contact/10/2004:ContactQueryPage";
           $param = "<ListOfContact>
           <Contact>
           <IntegrationId>='$contactid'</IntegrationId>

           <MrMrs/>
           <ContactFirstName/>
           <ContactLastName/>
           <JobTitle/>
           <Department/>
           <AccountName/>
           <AccountId/>
           <PrimaryAddress/>
           <PrimaryCity/>
           <PrimaryZipCode/>
           <PrimaryCounty/>
           <PrimaryCountry/>
           <AlternateAddress1/>
           <AlternateAddress2/>
           <AlternateAddress3/>
           <AlternateCity/>
           <AlternateZipCode/>
           <AlternateCounty/>
           <AlternateCountry/>
           <ContactEmail/>
           <WorkPhone/>
           <WorkFax/>
           <CellularPhone/>
           </Contact>
           </ListOfContact>
           ";
           $method = "ContactWS_ContactQueryPage_Input";

           $response = getwsresponse($serverpath,$namespace,$soapaction,$method,$param,$debug);

           return $response;
      }

      function getwsresponse($serverpath,$namespace,$soapaction,$method,$param,$headers=""){
           require_once('nusoap-0.9.5/lib/nusoap.php');
           $client = new nusoap_client($serverpath, array('trace' => 1));
           if($headers != ""){
                $client->setHeaders("$headers");
           }
           $response = $client->call($method,$param,$namespace,$soapaction);
           
           return $response;
      }

      But when i check : var_dump(getContactInfo("Integrationd",wslogin())); i have always false...

      I have no idea how to use this webservice. Can you help me ?

      Thanks !

      Edited by: 990614 on 27 févr. 2013 00:29