PHP code example of zgclives / bytedance
1. Go to this page and download the library: Download zgclives/bytedance 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/ */
zgclives / bytedance example snippets
use \Bytedance\BytedanceApp;
$app = new \Bytedance\BytedanceApp('appId', 'secret', 'salt', 'token');
$response = $app->login->accessToken();
$access_token = $response->accessToken;
$expires_in = $response->expiresIn;
$response = $app->login->code2Session($code);
return [
'session_key' => $response->sessionKey,
'openid' => $response->openId,
'unionid' => $response->unionId,
];
$access_token = $app->login->accessToken()->accessToken;
return $app->tool->createQRCode($access_token, $app->tool::APP_DOUYIN, 'pages/index/index');
$access_token = $app->login->accessToken()->accessToken;
return $app->tool->sendSubscribedMessage($access_token, $tpl_id, $open_id, $data, 'pages/index/index');
$response = $app->payment->createOrder($out_order_no, $total_amount, $subject, $body, $valid_time, $cp_extra, $notify_url);
return [
'order_id' => $response->orderId,
'order_token' => $response->orderToken
];
$response = $app->payment->queryOrder($out_order_no);
return $response;
//[totalFee] => 2
//[orderStatus] => SUCCESS
//[payTime] => 2021-08-26 17:38:49
//[way] => 1
//[channelNo] => 4321001296202108269673188430
//[channelGatewayNo] => 12108260167652952855
$response = $app->payment->createOrder($out_order_no, $total_amount, $subject, $body, $valid_time, $cp_extra, $notify_url);
return [
'order_id' => $response->orderId,
'order_token' => $response->orderToken
];
$response = $app->payment->createSettle($out_settle_no, $out_order_no, $settle_desc, $settle_params, $cp_extra, $notify_url);
return [
'settle_no' => $response->settleNo
];
$response = $app->payment->querySettle($out_order_no);
return [
'settle_no' => $response->settleNo,
'settle_status' => $response->settleStatus,
'settle_amount' => $response->settleAmount,
'settle_detail' => $response->settleDetail,
'settled_at' => $response->settleAt,
'rake' => $response->rake,
'commission' => $response->commission,
'cp_extra' => $response->cpExtra,
];