如何在PHP中从restapi获取LENDDO分数
如何在PHP中从REST API获取LENDDO分数如何在PHP中从restapi获取LENDDO分数,php,api,rest,curl,Php,Api,Rest,Curl,如何在PHP中从REST API获取LENDDO分数 我的客户id=LEDEMO107016878115774250 对于上述客户id,我的Lenddo分数为480,显示在我的Lenddo仪表板上,但不通过API获取此分数 不共享我的API和密钥 基本上,我需要在signRequest()函数中执行的生成授权头的帮助 引用= /* 我是Lenddo的首席开发人员。看来你正在走一条艰难的整合之路。感谢PHP(5.3+),我们实际上提供了一个SDK,使集成变得相当轻松 您可以在此处找到PHP SDK
我的客户id=LEDEMO107016878115774250
对于上述客户id,我的Lenddo分数为480,显示在我的Lenddo仪表板上,但不通过API获取此分数
不共享我的API和密钥
基本上,我需要在signRequest()函数中执行的生成授权头的帮助
引用=
/*
我是Lenddo的首席开发人员。看来你正在走一条艰难的整合之路。感谢PHP(5.3+),我们实际上提供了一个SDK,使集成变得相当轻松
您可以在此处找到PHP SDK:。在这一页上有自述文件,您可以在其中找到目录,更具体地说
由于您正在尝试检索分数,因此可以使用。在本页中,您将找到有关检索分数的说明
为了帮助您快速入门,我将在这里提供一个简要的说明列表(目前的情况):
composer require lenddo/sdk
/*
<?php
$method = "GET";
$date = date("D M j G:i:s T Y");
$url = '/ClientScore/LEDEMO1070168781157742500';
function signRequest($method, $body, $date, $url) {
$api = ''; //my api key
$secret = ''; // my secret key
$contentMd5 = NULL;
if( !empty( $body ) ) {
$contentMd5 = md5( $body );
}
$stringToSign = $method . "\n" . $contentMd5 . "\n" . $date . "\n" . $url;
$string = "LENDDO " . $api . ":";
$string .= base64_encode(
hash_hmac( "sha1", $stringToSign, $secret, TRUE )
);
return $string;
}
$val = signRequest('GET', '', $date, $url); // get the access token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://scoreservice.lenddo.com/ClientScore/LEDEMO1070168781157742500");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
$headers = array('Authorization: Bearer ' . $val);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
// the above source code gives me the output => string(141) "{"message": "Signature generated from request data does not match the signature provided in the Authorization Header.", "name": "FORBIDDEN"} "
// i pass my api and secret key into the code above but got this error, help me to find Lenddo Score.
?>