通过 PHP API 访问 MS Dynamics CRM [英] MS Dynamics CRM access through PHP API

查看:39
本文介绍了通过 PHP API 访问 MS Dynamics CRM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 PHP API 在 MS Dynamics CRM 中进行身份验证和执行 CURD 操作.

我参考了

最后,得到了这个使用 Web API 查询数据链接,但不知道如何使用 php 传递请求.

需要帮助以使用 api 检索 CRM 详细信息.

解决方案

这是关于从 PHP 连接到 Office365 rest api 的相当全面的教程.对于新的 CRM 2016/CRM 2015 WebApi 预览版,工作方式是相同的,只是端点和查询不同.

https://dev.outlook.com/RestGettingStarted/Tutorial/php

至于问题 2,如果您通过 azure 门户,则需要一张信用卡.您可能想查看新的 Office365 应用注册门户 http://dev.office.com/app-registration.我不确定它是否支持 Dynamics CRM.

I need to authenticate and perform CURD operations in MS Dynamics CRM using PHP API.

I have referred Reference1 Reference2 Reference3 Reference4

and using the below steps:

settings > 
Administration > 
system settings >
previews > 
accept terms & conditions > 
Web API Developer Preview  >
Enable Dynamics CRM Web API Preview to yes

which is given in Reference4 link.

When I access,

https://<your organization name>.crm.dynamics.com/api/data/contacts

and

https://<your organization name>.crm.dynamics.com/api/data/accounts

I can get all my contacts and accounts.

But now I want to access it through php using api,

  1. How to send the request for contacts and accounts?
  2. How to create an application using AAD for trail version without providing credit card details?

I tried the below code:

$ZDURL= 'https://www.microsoft.com/en-sg/dynamics/';    
curlWrap("GET",$ZDURL); 
function curlWrap($action,$ZDURL)
{
    $ch = curl_init();

    /* $data = array('accountType' => 'MICROSOFT DYNAMICS',
            'id' => '83261c03-3a21-4c64-b62c-00d6c2127c64',
            'source'=>'PHI-cUrl-Example',
            'service'=>'lh2'); */

    //curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, "username:password");

    curl_setopt($ch, CURLOPT_URL, $ZDURL);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

    $output = curl_exec($ch);
    if($output===false)
    {
        echo "curl error >> ".curl_error($ch);
        exit;
    }
    else
    {
        echo "No Curl error occurs";
        echo "<pre>";print_r($output);
    }
    exit;
    curl_close($ch);
    $decoded = json_decode($output);

    return $decoded;
}

It shows as below:

Finally, got this Query Data using the Web API link, but no idea how to pass the request using php.

Need a help to retrieve CRM details by using api.

解决方案

This is quite a comprehensive tutorial on connecting to Office365 rest api's from PHP. For the new CRM 2016 / CRM 2015 WebApi preview, the workings are the same, only the endpoint and the query is different.

https://dev.outlook.com/RestGettingStarted/Tutorial/php

As for issue number 2, if you go through the azure portal, you need a credit card. You might want to check out the new Office365 app registration portal http://dev.office.com/app-registration. I don't know for sure if it supports Dynamics CRM.

这篇关于通过 PHP API 访问 MS Dynamics CRM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆