您可以讓PHP直接和安全地與CRM交談。額外的橋樑只是開銷,實際上並沒有提供太多好處。
這裏有一個博客帖子與CRM在線PHP的輔助類: http://www.hashtagcrm.com/?p=17
與助手剛開始,然後您需要任何特定的功能擴展。該助手甚至還包括一個樣本函數,演示如何添加自己的特定功能:在你的主程序
//Returns the Parent Account Name of the specified Contact
public function sampleFunction($contactid){
$getParentCustomer = '
<Retrieve xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<entityName>contact</entityName>
<id>'.$contactid.'</id>
<columnSet xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<a:AllColumns>false</a:AllColumns>
<a:Columns xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>parentcustomeridname</b:string>
</a:Columns>
</columnSet>
</Retrieve>';
$getParentCustomerResult = $this->sendQuery($getParentCustomer, 'Retrieve');
$responsedom = new DomDocument();
$responsedom->loadXML($getParentCustomerResult);
$KeyValuePairs = $responsedom->getElementsbyTagName("KeyValuePairOfstringanyType");
foreach($KeyValuePairs as $results) {
if ($results->childNodes->item(0)->nodeValue == "parentcustomeridname") {
return $results->childNodes->item(1)->childNodes->item(0)->nodeValue;
}
else {
return 'No Result';
}
}
}
然後,你可以運行這樣的事情:
require_once('dynamicsclient.php');
$dynamicsClient = new dynamicsClient(0);
//prints the Parent Account name of the specified Contact ID
echo $dynamicsClient->sampleFunction("<CONTACTID>");
添加SSL/TLS到主機運行web服務,並確保您的php使用用戶名/密碼/密鑰系統對應用程序進行身份驗證,您會沒事的。 – Dave 2014-11-21 13:41:06
感謝您的回覆,戴夫。我當然希望我能夠將SSL放在主機上,但問題是我可能無法始終控制服務器,但我仍然需要確保它的安全;所以如果你必須不使用SSL,那你會怎麼做? – 2014-11-21 18:16:51
如果SSL不是選項,則必須使用消息級別加密來確保通信免受嗅探攻擊。查看WCF消息安全性。 http://msdn.microsoft.com/en-us/library/ff648863.aspx – MvdD 2014-11-21 23:33:10