php开放平台,顺丰开放平台API PHP SDK demo

顺丰开放平台Api PHP SDK demo

引用

对接前期工作注册

提交接入申请

接口初始化配置,获得 app_id 和app_secret

完成测试环境测试

进入生产使用

接入注意事项申请令牌 (/security/access_token/ 接口)

access_token 有效期为 1 小时,过期需使用 refresh_token 刷新令牌(/security/refresh_token/ 接口)

refresh_token 有效期为当天 24 点,过期需重新申请(/security/access_token/ 接口)

接口均为 https ,数据传输格式为 json

Demo

SDK Demo<?php

/**

* 顺丰 api 接口使用

* Date: 2017/10/19

* Time: 9:36

* @author zlh

*/

class SfApi {

/**

* @var string

*/

protected $app_id;

/**

* @var string

*/

protected $app_key;

/**

* @var string

*/

public $access_token;

/**

* @var string

*/

public $refresh_token;

/**

* @var string

*/

private $uri;

/**

* SfApi constructor.

* @param string $app_id

* @param string $app_key

* @param bool $online

* @return void

*/

public function __construct ($app_id, $app_key, $online = false) {

$this->app_id = $app_id;

$this->app_key = $app_key;

$this->url = $online ? 'https://open-prod.sf-express.com/' : 'https://open-sbox.sf-express.com/';

}

/**

* 快速创建订单

* @param array $req_body

* @return bool|string

*/

public function order ($req_body) {

$req_body = array(

'orderId' => $req_body['orderId'],

'expressType' => $req_body['expressType'],

'payMethod' => $req_body['payMethod'],

'custId' => $req_body['custId'],

'payArea' => isset($req_body['payArea']) ? $req_body['payArea'] : 'SFCM10008035754399',

//'remark' => $req_body['remark'],

'consigneeInfo' => array(

'company' => isset($req_body['consigneeInfo']['company']) ? $req_body['consigneeInfo']['company'] : '个人',

'contact' => $req_body['consigneeInfo']['contact'],

'tel' => $req_body['consigneeInfo']['tel'],

'province' => $req_body['consigneeInfo']['province'],

'city' => $req_body['consigneeInfo']['city'],

'county' => $req_body['consigneeInfo']['county'],

'address' => $req_body['consigneeInfo']['address'],

'mobile' => $req_body['consigneeInfo']['mobile'],

),

'cargoInfo' => array(

'cargo' => $req_body['cargoI

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值