project wb_sdk
哪儿借开放平台sdk
baykier/wb_sdk
哪儿借开放平台sdk
- Wednesday, September 6, 2017
- by baykier
- Repository
- 1 Watchers
- 0 Stars
- 11 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 175 % Grown
wb_sdk
哪儿借JsonRpc SDK, (*1)
install 安装
composer require baykier/wb_sdk
usage 使用
- 作为client 参考client.php
use Wb\Client;
use Wb\Request;
require_once __DIR__ . '/vendor/autoload.php';
defind('RSA_PRIVATE_KEY','
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAz4pCNC7epGRpyjkuQzVgOQ07OUXN9Xr8mbeNqEniKsZHJfbX
YU7HZ8AqHNADNAqiMY30nsz1qPAXOjFVMChrI5fmKjvZZqih57r7AHi322qby5SI
6O5HbPyw2NmAB911cHE4lpQue7juHQ2m71KXJtwFqNhxwpWrPJkOucbwOF1iOgWe
tbTR46mwKEopk+yZwY0EYKN8RtTW62J9B0HrpLYMbWQusarHL5EHP6oI8W0Pcks8
ZrwejCZ8iJ2w8DnNcn/WYsLcWgkk1jjqhedxHqRb3wqWk6y26uR9uSryEWr+7PNN
I8ON37xH8AxA5jtZVBqj2d5pLe7LVTKN+virgwIDAQABAoIBAF4TMt1KnZtw9M84
yjKm4D4cNEtKzAhJPnVDUdAF5aI0DI417P1r41GxNqWm2LzfURQbX9YX3Ac/BZhY
QmA5Ag+5TBi61loFeJZ9GEfncJfiJErMwp6rW+8YP+Wb+cAW76QPfnIrK0Lj2fOL
e68iBegUdfBKZI6qn1sxmg42Ei/JuqnWvgmvlAzzzpxj94mo7Ko8WlPS1pX6qoiq
H20ukzt7alZDVnNY3r7mJPfnfuQoDRWr2RgNog8QRquFqzHMuAcizqUD9HrmoqZK
KLxAeIKMtossY6iIkN8xjv6sVnBmIjKpATXDAyrQbA1ATVC++BaeQozSz1tdZNGQ
amPftxkCgYEA/2t0FlVQJtq0bSTJ6N2j5Oz0W6ecIx7yE5QW3OoNvEGExXZ1jRVk
9wxqNN8zkH16MG9M6eZnAIgoed/lFTAb0clvcsd/Xouv1Y/7bJFfDpEP3DVuDnBZ
ypv9chELtRDCWzIEc043lFUUYBeAbjlLOMjlSA+QjkVAPRXe3t2GRJ8CgYEA0AL1
maRugvWEqSNP0rRMSdfEdPtWw3rlXqa8Bc55cLvEI15T46zFv2MK78vpDO92u+gJ
2sDfDEZYFTA8qlX55Pr7vlMNbfoZUeusBRLzY/dVA0UbLQ08PzgfbZ5SMU1iTpmH
o+hqzErqcUfSJT1HVDn6FgFKDaFHiCnteOiRqp0CgYABVTg33Z4bdcy3PRfopS9z
xGDKEafY7xJoU7+Cy53iu5zLwwB+CfyK5X+wYvHL8TuwAQSvu8oR0KQVbrutTqD2
iUyRlsTtY2E5hhTTzjZmxw8EISs/3Ao76nB6Jeifu0SoYSxwxZm4pnECx1yeNqJT
24iGxb4FYAsjxndxRkqrFQKBgCdCN7pMt3LOBcCqYnlg//j72R8/BIwWWM35aAks
g+0L8yO9vNV+mT/a4IiLkquXUnB6hcmclzxI1n0BQqHfYi+eUv8Dy8gS6M52TVwT
zI30cz4Pv+ZL1jAUVpIozFhzw3cUMO51ghqWlRLWPEo8+4Zg/ttCWQijhM2lJCWq
tztdAoGARHi05COrPo2NamX+fdB640JO5OiSYZpPVgrAGsV/xKBAgtun3YFB/Inv
pvijeusDfpMLH1k8UGXSpVrZ8Ofl2iKBGpVS5SlhnrCmTNvZZs1c3nPwtQzmFmRx
+szNK+oodEO7WZ08159k1eM+OCn5r9Q19qDVTWQ7hETNkx+3E8A=
-----END RSA PRIVATE KEY-----
');
$client = new Client();
$client->setAppId('170040');
$client->setApiUrl('https://dev.wb_sdk/server.php');
$client->setRsaPrivateKey(RSA_PRIVATE_KEY);
$client->setMethod('queryOrderStatus');
$client->setBizData(array('order_num' => '1212'));
$resp = $client->send();
var_dump($resp);
- 作为server使用 参考server.php
use Wb\Server as BaseServer;
use JsonRPC\Exception\ServerErrorException;
require_once __DIR__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yu6QDrLYDeHzFpo3AwMe7WWJYxtwoc0020pAw+t
LWno53nX2HoDN6r8fcw5oLJovnEyc2Y1LRRKL2zrK9zBfzZhA85+NDwQwK6EbII1
3pur3Q1+1+k+Ts6EmFCM9YXiz7XCFskCogWHOb7B+4QXlb3kCz9/C+K+Vw==2
-----END CERTIFICATE-----
');
/**
* 自定义服务端接口
* Class Server
*/
class Server extends BaseServer
{
/**
* 查询订单状态接口
* @JsonRpcMethod query order status
* @param $params
* @return array
* @throws ServerErrorException
*/
public function queryOrderStatus($params)
{
$this->parseParams($params);
// 业务逻辑
// 返回订单状态
return array(
'order_num' => '17170031080415815952',
'status' => '11',
'update_time' => '2017-08-13 14:34:00',
);
}
}
$server = new Server();
$server->setRsaPublicKey(RSA_PUBLIC_KEY);
echo $server->execute();