dtx6087 2015-12-07 06:36
浏览 43

通过PHP API访问MS 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:

enter image description here

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.

  • 写回答

1条回答 默认 最新

  • drlq92444 2015-12-11 12:41
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集