【问题标题】:Add new contact record to Dynamics CRM via REST call通过 REST 调用将新联系人记录添加到 Dynamics CRM
【发布时间】:2011-07-09 00:29:12
【问题描述】:

对 Dynamics 的工作原理一无所知,我对它的数据模型一无所知(我也不懂它的术语,所以如果我使用了错误的术语,我提前道歉)。

我正在建立一个网站,当有人在该网站上填写表格时,需要在 Dynamics CRM 中创建一条新记录(我相信是 2011 年的最新版本)。

本网站是用 PHP 构建的,因此 MS 提供的许多示例代码并不适用。理想情况下,我正在寻找一些说明或教程链接,如下所示:

  1. 向此网址发出 POST 请求:http://myinstallation.com/address/to/rest/endpoint
  2. 向它传递以下参数:
    • 'password':应用密码
    • 'firstName':联系人名字
    • 'lastName':联系人姓氏
    • 'address1':街道地址的第一行 等等等等。
  3. 它将以 JSON 字符串形式返回以下信息:
    • 'error code':0表示成功,否则为错误号
    • 'error message':错误描述(如果有)

我知道在 CRM 中可能没有简单的“联系人”概念,而是“机会”、“人员”和“组织”的某种组合。而且我知道您可能不只是向它发送密码,而是发送一些身份验证令牌或 cookie 数据。而且我知道它可能需要 SOAP 调用而不是 REST 调用(尽管最新版本似乎支持 REST,我更喜欢它,因为它更简单)。而且我知道它可能不会返回 JSON 字符串。我在上面发布的只是我理想答案的格式示例(不是试图要求,只是我知道有时在 MS 和 PHP 世界之间会“迷失在翻译中”,所以希望这有助于解释什么对我虚弱的大脑的一个有用的答案看起来像)。

或者也许我完全不在基地,如果没有在 Dynamics 方面的大量定制,做这种事情是不可能的?

顺便说一句,我目前不关心“双向同步”,所以我只需要告诉 CRM 有一个新联系人(理想情况下,它会自动标记它认为重复的记录,但这不是必需的)。

感谢您提供的任何指导或帮助。

【问题讨论】:

    标签: php dynamics-crm


    【解决方案1】:

    我遇到了同样的问题,在拉了一堆头发之后(在此期间我在这里看到了你的帖子),我找到了这个人,他以非常合理的价格提供了一个预构建的 PHP 库,可以满足你的需求需要:

    http://www.zenithies.org/articles/articles/6/microsoft-dynamics-crm-4-0-php-integration-offer.html

    我正在将他的代码与我的生产应用程序集成,但这里是您处理的界面,非常接近您正在寻找的:

    $bridge = new CrmExt();
    $bridge->liveUser = 'username@domain.com';
    $bridge->livePassword = 'password';
    $bridge->crmDiscoveryHost = 'domain.crm.dynamics.com';
    $bridge->crmDiscoveryHostHttps = true;
    $bridge->crmAddress = 'domain.crm.dynamics.com';
    $bridge->crmHost = 'domain.api.crm.dynamics.com';
    $bridge->crmHostHttps = true;
    
    try {
        $bridge->connnect();
    
        $newContact = array(
            'firstname' => 'John',
            'lastname' => 'Doe',
            'emailaddress1' => 'example@example.com',
            'telephone1' => '+420 000 000 000 000',
            // etc ..
        );
    
        // This will send account into crm
        $newContactId = $bridge->pushContact( $newContact );
    } catch (Exception $e) {
        printf(
            '<h1>Error:</h1><ul><li>%s</li></ul><pre>%s</pre>',
            $e->getMessage(),
            $bridge->dump(true)
        );
    }
    

    【讨论】:

    • 您完成集成了吗?有你想象的那么成功吗?我已联系 Zenithies 获取报价 - 我对非常相似的解决方案非常感兴趣。
    • 我还没有完全完成,项目有点被搁置了,但到目前为止一切都很好,我从 Zenithies 得到的一切正是我所需要的,并且正如广告所宣传的那样工作。物有所值。
    • 我刚刚得到了我的项目的报价 - 这会很划算,但他的解决方案不适用于 On Premise CRM - 仅适用于托管品种。太糟糕了!
    • 对不起,我用的是托管的,没想到和现场有区别。 :(
    【解决方案2】:

    我用过这个类:https://github.com/Ben-Speakman/PHP-Dynamics-Online-CRM-2011-SOAP-Class

    并像这样请求:

    $request = '<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                               <request i:type="a:CreateRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
                                <a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
                               <a:KeyValuePairOfstringanyType>
                               <b:key>Target</b:key>
                                <b:value i:type="a:Entity">
                                <a:Attributes>
                              <a:KeyValuePairOfstringanyType>
                                <b:key>firstname</b:key>
                                <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">name</b:value>
                               </a:KeyValuePairOfstringanyType>
                               <a:KeyValuePairOfstringanyType>
                                <b:key>lastname</b:key>
                                <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">lastname</b:value>
                               </a:KeyValuePairOfstringanyType>
                              <a:KeyValuePairOfstringanyType>
                                <b:key>department</b:key>
                                <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">department_name</b:value>
                               </a:KeyValuePairOfstringanyType>
                                <a:KeyValuePairOfstringanyType>
                                <b:key>emailaddress1</b:key>
                                <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">email@yahoo.com</b:value>
                               </a:KeyValuePairOfstringanyType>
                                <a:KeyValuePairOfstringanyType>
                                <b:key>telephone1</b:key>
                                <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">00112233</b:value>
                               </a:KeyValuePairOfstringanyType>
                             <a:KeyValuePairOfstringanyType>
                                <b:key>description</b:key>
                                <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">bla bla</b:value>
                               </a:KeyValuePairOfstringanyType>
                               <a:KeyValuePairOfstringanyType>
                              <b:key>address1_country</b:key>
                              <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">My country</b:value>
                               </a:KeyValuePairOfstringanyType>
                                             </a:Attributes>
                                             <a:EntityState i:nil="true" />
                                             <a:FormattedValues />
                                             <a:Id>'.$dynamicsClient->create_guid().'</a:Id>
                                             <a:LogicalName>contact</a:LogicalName>
                                             <a:RelatedEntities />
                                           </b:value>
                                         </a:KeyValuePairOfstringanyType>
                                       </a:Parameters>
                                       <a:RequestId i:nil="true" />
                                       <a:RequestName>Create</a:RequestName>
                                     </request>
                                   </Execute>';
    
                        $dynamicsClient->sendQuery($request);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多