PHP code example of lingxi / api-authentication
1. Go to this page and download the library: Download lingxi/api-authentication library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lingxi / api-authentication example snippets
use Lingxi\Signature\Authenticator;
'secret');
$data = [
'id' => 'cawzyvopker1gdxeqx82w6qm2x5l73n8',
];
echo 'http://api.lingxi.com/v1/partner/cms/content/show?' . http_build_query($auther->getAuthParams($data)) . PHP_EOL;
use Lingxi\Signature\Client;
$apiClient = new Client(
$partner->partner_key,
$partner->partner_secret
);
try {
$response = $apiClient->order('id', 'asc')->get('/contact/show');
// get response data
$data = $response->getResponseData();
// 大部分接口,response data 包含 data 和 meta 两部分,可以:
$data = $response->getData();
$meta = $response->getMeta();
// 也支持作为对象属性获取
$data = $response->data;
$meta = $response->meta;
} catch (\Exception $e) {
// deal with it...
}