Home > php教程 > php手册 > body text

Collect news API

WBOY
Release: 2016-12-05 13:27:45
Original
1295 people have browsed it

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>

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!