送件侠开放平台

闪时送开放平台


php demo文件(快速对接)

<pre><code>&amp;lt;?php class Demo { private $appKey = &amp;quot;x&amp;quot;; private $appSecret = &amp;quot;y&amp;quot;; private $shopId = 1; /** 此处调用最简单的`查询余额接口`,这个方法如有正常返回数据,则表示签名通过了. */ function queryBalance() { // 系统参数(固定参数) $sysParams = [ &amp;quot;appkey&amp;quot; =&amp;gt; $this-&amp;gt;appKey, &amp;quot;timestamp&amp;quot; =&amp;gt; time(), &amp;quot;version&amp;quot; =&amp;gt; &amp;quot;1.0&amp;quot;, ]; // 接口参数 $apiParams = [ &amp;quot;sss_shop_id&amp;quot; =&amp;gt; $this-&amp;gt;shopId, ]; // 获取签名 $sign = $this-&amp;gt;makeSign($apiParams, $sysParams[&amp;quot;timestamp&amp;quot;], $this-&amp;gt;appSecret); // 组装最终的请求参数 $params = array_merge($sysParams, $apiParams); $params[&amp;quot;sign&amp;quot;] = $sign; // 请求开放平台接口 $result = json_decode( $this-&amp;gt;httpPost(&amp;quot;https://peisongopen.51sssong.com/api/v1/shop/queryBalance&amp;quot;, $params), true ); if(isset($result[&amp;quot;code&amp;quot;]) &amp;amp;&amp;amp; $result[&amp;quot;code&amp;quot;] == 0) { // code:0表示接口响应正常并且成功 var_dump( $result ); } else { // 接口异常 var_dump( $result ); } exit; } /** * 签名 * @param array $param * @param int $time * @return string */ function makeSign($param, $time, $appSecret = &amp;quot;&amp;quot;) { $version = &amp;quot;1.0&amp;quot;; $tmpArr = array( &amp;quot;appkey&amp;quot; =&amp;gt; $this-&amp;gt;appKey, &amp;quot;timestamp&amp;quot; =&amp;gt; $time, &amp;quot;version&amp;quot; =&amp;gt; $version, ); foreach ($param as $k =&amp;gt; $v) $tmpArr[$k] = $v; ksort($tmpArr); if($appSecret) { $str = $appSecret; }else { $str = $appSecret; } foreach ($tmpArr as $k =&amp;gt; $v) { if ($v === false) $v = 'false'; if ($v === true) $v = 'true'; if (empty($v) &amp;amp;&amp;amp; $v != 0) continue; $str .= $k . $v; } $signature = sha1($str); return strtolower($signature); } /** * POST 请求 * @param string $url * @param array $param * @param boolean $post_file 是否文件上传 * @return string content */ function httpPost($url, $param, $post_file = false) { $oCurl = curl_init(); if (stripos($url, &amp;quot;https://&amp;quot;) !== FALSE) { curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1 } if (is_string($param) || $post_file) { $strPOST = $param; } else { $aPOST = []; foreach ($param as $key =&amp;gt; $val) { $aPOST[] = $key . &amp;quot;=&amp;quot; . urlencode($val); } $strPOST = join(&amp;quot;&amp;amp;&amp;quot;, $aPOST); } curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($oCurl, CURLOPT_POST, true); curl_setopt($oCurl, CURLOPT_POSTFIELDS, $strPOST); curl_setopt($oCurl, CURLOPT_TIMEOUT, 10); $header = array( 'application/x-www-form-urlencoded', ); curl_setopt($oCurl, CURLOPT_HTTPHEADER, $header); $sContent = curl_exec($oCurl); curl_close($oCurl); return $sContent; } } $result = (new Demo()) -&amp;gt; queryBalance(); var_dump($result);</code></pre>

页面列表

ITEM_HTML