Home  >  Article  >  php教程  >  Collect news API

Collect news API

WBOY
WBOYOriginal
2016-12-05 13:27:451297browse

Collecting news
https://www.showapi.com/api/lookPoint/1071//md5 signature method--not a simple signature<br>                                                                                 header("Content-Type:text/html;charset=UTF-8");<br> date_default_timezone_set("PRC");<br> $showapi_appid = 'xxxxxx'; //Replace this value and find the relevant value in "My Application" on the official website<br> $showapi_secret = 'xxxxxxxxx'; //Replace this value and find the relevant value in "My Application" on the official website <br> $paramArr = array(<br> 'showapi_appid'=> $showapi_appid<br> //Add other parameters<br> );<br> <br> //Create parameters (including signature processing)<br> function createParam ($paramArr,$showapi_secret) {<br> ​ ​ $paraStr = "";<br> $signStr = "";<br> ​​ksort($paramArr);<br> foreach ($paramArr as $key => $val) {<br> If ($key != '' && $val != '') {<br> $ SIGNSTR. = $ Key. $ Val; <br>                    $paraStr .= $key.'='.urlencode($val).'&';<br>          }<br> }<br> $signStr .= $showapi_secret;//Add secret to the sorted parameters and perform md5<br> $sign = strtolower(md5($signStr));<br> $paraStr .= 'showapi_sign='.$sign;//Use the value after md5 as a parameter to facilitate server validation<br> echo "Sorted parameters:".$signStr."<br>rn";<br> Return $paraStr;<br> }<br> <br> $param = createParam($paramArr,$showapi_secret);<br> $url = 'http://route.showapi.com/1071-1?'.$param; <br> echo "Requested url:".$url."<br>rn";<br> $result = file_get_contents($url);<br> echo "Returned json data:<br>rn";<br> print $result.'<br>rn';<br> $result = json_decode($result);<br> echo "<br>rnGet the value of showapi_res_code:<br>rn";<br> print_r($result->showapi_res_code);<br> echo "<br>rn";<br> ?><br>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:WeChat Small Mall 1.1Next article:WeChat Small Mall 1.1