我想获得D& B API版本2 REST方法的身份验证令牌
http://developer.dnb.com/docs/2.0/common/authentication-process
示例请求 - 获取新令牌
POST https://maxcvservices.dnb.com/rest/Authentication
x-dnb-user:P2000000FD4A9DE85D848229E03507C8
x-dnb-pwd:volcano
我已经在Chrome扩展程序(高级REST客户端)上测试了这些凭据,但它们运行良好。
所以现在我如何使用PHP代码实现这一点,请帮助
由于
答案 0 :(得分:1)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://maxcvservices.dnb.com/rest/Authentication');
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('x-dnb-user: P2000000FD4A9DE85D848229E03507C8','x-dnb-pwd: volcano'));
$param_array = array();
$param_query_string = http_build_query($param_array);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param_query_string);
$response = curl_exec($ch);
我与DnB技术团队进行了讨论,他们向我发送了.NET示例代码,我学习了代码并使用PHP应用了相同的逻辑,最终工作正常。