|
整个代码就是这样的吧,用的是你们的那个SDK的PHP版本,结果出来一二维码扫打开还是404页面。。。
<?php
require_once __DIR__ . '/lib/YZGetTokenClient.php';
require_once __DIR__ . '/lib/YZTokenClient.php';
//自用型应用获取token
$client_id = "我的client_id";//请填入有赞云控制台的应用client_id
$client_secret = "我的client_secret";//请填入有赞云控制台的应用client_secret
$token = new YZGetTokenClient( $client_id , $client_secret );
$type = 'self';
$keys = array(
'grant_type' => 'silent',
'kdt_id' => '我的店铺ID',//店铺ID
);
$tokenarr = $token->get_token( $type , $keys );
$access_token = $tokenarr['access_token'];
$client = new YZTokenClient($access_token);//请填入商家授权后获取的access_token
$method = 'youzan.pay.qrcode.create'; //要调用的api名称
$api_version = '3.0.0'; //要调用的api版本号
$my_params = [
'qr_name' => '測試',
'qr_price' => '1',
'qr_type' => 'QR_TYPE_DYNAMIC',
];
$my_files = [];
/*
echo '<pre>';
var_dump(
$client->get($method, $api_version, $my_params, $my_files)
);
echo '</pre>';
*/
$resp = $client->post($method, $api_version, $my_params);
if (!isset($resp['response'])) {
var_dump($resp);
} else {
$qr = $resp['response'];
$qr_id = $qr['qr_id'];
$qr_code = $qr['qr_code'];
}
echo "<img src='".$qr_code."'>";
?>
|
|
|
|
|
|
|