cod*_*bie 6 php joomla microsoft-dynamics dynamics-crm dynamics-crm-webapi
在一个Joomla应用程序我得到一个用户信息如下,然后我需要保存用户信息通过自己的REST API的动态365数据库中的联系人.
$user = JFactory::getUser();
$username = $user->username;
$name = $user->name;
Run Code Online (Sandbox Code Playgroud)
我环顾周围的Web API和REST API像动态文档这个和这个,但他们没有提供有用的信息,我怎么能调用API来添加新的联系人.:目前,我通过这个网址连接365动态Web应用程序http://example.com:8088/mysite/api/data/v8.2.链接的帖子也讨论了REST API,但只是查询.我正在寻找一种使用REST API将数据发布到Dynamics CRM的方法.
使用crm webapi创建Contact的有效负载将如下所示:阅读更多内容
POST [Organization URI]/api/data/v8.2/contacts HTTP/1.1
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
{
"firstname": "Arun",
"lastname": "Vinoth"
}
Run Code Online (Sandbox Code Playgroud)
抱歉,我不是来自PHP背景,但此链接可能对您有所帮助.
更新:
我浏览了一下.从SO答案中找到以下代码示例.例如,[Organization URI]使用CRM URL 更新https://testorg.crm.dynamics.com
$url = '[Organization URI]/api/data/v8.2/contacts';
$data = array('firstname' => 'Arun', 'lastname' => 'Vinoth');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
Run Code Online (Sandbox Code Playgroud)