Created
November 28, 2016 12:25
-
-
Save notgosu/48f140562e563a56cdfb99713f74ff00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function CreateLead($authHeader, $url) | |
{ | |
$newName = "Test-name-vintage"; | |
$email = "vintage@vintage.com.ua"; | |
$phone = "111111111"; | |
$desc = ''; | |
$lang = ''; | |
$pageUrl = ''; | |
$formData = ''; | |
$productUrl = ''; | |
$quantity = 0; | |
$source = ''; | |
$companyType = ''; | |
$newId = "00000000-0000-0000-0000-000000000000"; | |
try { | |
$xml = "<s:Body>"; | |
$xml .= "<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">"; | |
$xml .= "<request i:type=\"a:CreateRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" >"; | |
$xml .= "<a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>Target</b:key>"; | |
$xml .= "<b:value i:type=\"a:Entity\">"; | |
$xml .= "<a:Attributes>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>FirstName</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $newName . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>EMailAddress1</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $email . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>MobilePhone</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $phone . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>Description</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $desc . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_language</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $lang . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_page_url</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $pageUrl . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_form_id</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $formData . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_product</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $productUrl . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_Quantity</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $quantity . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_source</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $source . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "<a:KeyValuePairOfstringanyType>"; | |
$xml .= "<b:key>new_companytype</b:key>"; | |
$xml .= "<b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" . $companyType . "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "</a:Attributes>"; | |
$xml .= "<a:EntityState i:nil=\"true\" />"; | |
$xml .= "<a:FormattedValues xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\" />"; | |
$xml .= "<a:Id>" . $newId . "</a:Id>"; | |
$xml .= "<a:LogicalName>lead</a:LogicalName>"; | |
$xml .= "</b:value>"; | |
$xml .= "</a:KeyValuePairOfstringanyType>"; | |
$xml .= "</request>"; | |
$xml .= "</Execute>"; | |
$xml .= "</s:Body>"; | |
$executeSoap = new CrmExecuteSoap (); | |
$response = $executeSoap->ExecuteSOAPRequest ( $authHeader, $xml, $url ); | |
var_dump($response);exit; | |
} catch (\Exception $e) { | |
echo 'Выброшено исключение: ', $e->getMessage(), "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment