码迷,mamicode.com
首页 > Web开发 > 详细

阿里云 金融接口 token PHP

时间:2018-05-01 12:33:22      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:body   utf-8   exp   接口   阿里云   nsf   var   verify   pre   

 

    public function getToken()
    {
        $host = "http://apush1.market.alicloudapi.com";
        $path = "/getToken";
        $method = "POST";
        $appcode = "79c1ffbdb178459c955d41355dfcf88f";
        $headers = array();
        array_push($headers, "Authorization:APPCODE " . $appcode);
        //根据API的要求,定义相对应的Content-Type
        array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
        $querys = "";
        $bodys = "appId=24645837&userId=userTest1&expireAfterSeconds=60";
        $url = $host . $path;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        //curl_setopt($curl, CURLOPT_HEADER, true);
        if (1 == strpos("$".$host, "https://"))
        {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        }
        curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
        //var_dump(curl_exec($curl));
        echo(curl_exec($curl));
    }

 

阿里云 金融接口 token PHP

标签:body   utf-8   exp   接口   阿里云   nsf   var   verify   pre   

原文地址:https://www.cnblogs.com/shaoing/p/8975719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!