返回 第三方接口编写... 登陆

第三方接口编写

1 2019-07-09 10:27:20 288

/****

 * @param $url

 * @param $post_data

 * @return bool|string

 * 第三方物流接口请求

 */

function send_post($url,$post_data) {

 

 

    $postdata = http_build_query($post_data);

    $options = array(

        'http' => array(

            'method' => 'POST',

            'header' => 'Content-type:application/x-www-form-urlencoded',

            'content' => $postdata,

            'timeout' => 15 * 60 // 超时时间(单位:s)

        )

    );

    $context = stream_context_create($options);

    $result = file_get_contents($url, false, $context);

 

    return $result;

}

 

  $order_number="订单号";

 

  $post_data = array(

      'company_id' => '开放平台ID',

      'msg_type' => 'TRACEINTERFACE_NEW_TRACES',

      'data' => "[\"$order_number\"]",

      'data_digest' => '签名'

  );

 

$data =send_post("http://japi.zto.cn/gateway.do",$post_data);

 

echo $data;


最新手记推荐

• 用composer安装thinkphp框架的步骤 • 省市区接口说明 • 用thinkphp,后台新增栏目 • 管理员添加编辑删除 • 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网