-3
Hello, all good?
I am very beginner in PHP, and I am integrating a client’s CRM with a form for capturing Leads. Their system is small in scope, and the only thing I have to help me with is a document with some instructions - in addition to searches here in the OS and on the Internet.
On Google, I found some solutions for validation, necessary step before sending the form. I tested and everything worked out - I am working with the following code:
<?php
$client = new SoapClient('http://crm4u.azurewebsites.net/WS_Integracao.asmx?WSDL');
$function = 'GetToken';
$arguments= array('GetToken' => array(
'ApiKey' => XXXXXXXX
));
$options = array('location' => 'http://crm4u.azurewebsites.net/WS_Integracao.asmx');
$result = $client->__soapCall($function, $arguments, $options);
$json = $result->GetTokenResult;
$item = json_decode($json, true);
print_r($item);
$apikey = 'XXXXXXXX';
$apipassword = 'YYYYYYYY';
$combinacao = $apikey."|".$apipassword."|".$item;
$combinacaomd5 = md5($combinacao);
$tokenfinal = $combinacaomd5."|".$apikey;
print_r($tokenfinal);
?>
Now that I have the token validated for sending the form, I need to understand how to send the data of a form in the following format:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:PutLead>
<tem:pessoa>
<tem:Nome>Nome do lead</tem:Nome>
<tem:Email>[email protected]</tem:Email>
<tem:Telefone>11 99999-9999</tem:Telefone>
<tem:Observacoes>Observações do lead</tem:Observacoes>
</tem:pessoa>
<tem:Key>TOKEN GERADO PELO CÓDIGO ANTERIOR</tem:Key>
</tem:PutLead>
</soapenv:Body>
</soapenv:Envelope>
If the request is successfully completed, we should get the return of the lead ID - as code below:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PutLeadResponse xmlns="http://tempuri.org/">
<PutLeadResult>ID DO LEAD</PutLeadResult>
</PutLeadResponse>
</soap:Body>
</soap:Envelope>
I have done a lot of research, but I haven’t found anything relevant on the subject - I don’t even know if it’s the best way to do this. I preferred to follow with PHP because I have some affinity. Someone can give me a light?
Thank you very much!
Light => PHP:SOAP
– Augusto Vasques