JavaScript-How the Baidu API should be used to solve the great God

Source: Internet
Author: User
Tags curl sample
API store's top featured API

 interface Address: Http://apis.baidu.com/txapi/weixin/wxhot Request method: Get request parameter (header): Parameter name type required argument location description default value Apikeystrin G is the header API key your own Apikey request parameter (urlparam): Parameter name type required parameter location description default value Numnumber is Urlparam article return number Volume 10randnumber no urlparam random, 1 means random 1wordstring no Urlparam search keywords tomb grave Note pagenumber no Urlparam page, output number Volume following num parameter 1srcstring no Urlparam specified article source People's Daily request example: Curl sample PHP Sample Python sample Java sample C # example OBJECTC Example Swift Example 1!--? php2 $ch = Curl_init (); 3 $url = ' http://apis.baidu.com/txapi/weixin/wxhot?num=10&rand=1&word=%E7%9B%97%E5%A2%93%E7%AC%94%E8% Ae%b0&page=1&src=%e4%ba%ba%e6%b0%91%e6%97%a5%e6%8a%a5 '; 4 $header = Array (5 ' Apikey: Your own Apikey ', 6); 7//Tim Add Apikey to Header8 curl_setopt ($ch, Curlopt_httpheader, $header); 9 curl_setopt ($ch, Curlopt_returntransfer, 1); 10 Execute HTTP Requests curl_setopt ($ch, Curlopt_url, $url), $res = Curl_exec ($ch), 1314 var_dump (Json_decode ($res)); 15? -->
JSON return Example: {"Code": 200,//Return Status Code "MSG": "Success",//Return status message "Newslist": [{"CTime": "2016-0 3-31 ",//Article release time" title ":" Qihoo 360 announces adoption of privatization resolution ",//Text title" description ":" Internet Headline ",//Source and description" pic URL ":" http://t1.qpic.cn/mblogpic/f01a972dbcc1060fd456/2000 ",//article illustration, null as Default" URL ":" Http://mp.weixin.qq.com/s?__            Biz=mjm5otmyoda2ma==&idx=1&mid=402594468&sn=5cd644536b472a283cc1d3f5124a0cab "},//article URL { "CTime": "2016-03-31", "title": "Small business to make money 17 size of the business recommendation", "description": "The forefront of Entrepreneurship", "pic URL ":" http://zxpic.gtimg.com/infonew/0/wechat_pics_-4225297.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz= Mza3njgznduwmq==&idx=2&mid=401864059&sn=cfa082e38ba38c7e673b1ce0a075faee "}, {" CTime            ":" 2016-03-31 "," title ":" When the poor tour from the online community to the offline travel service providers turn around, start a business than forget the "big platform" This matter, "description": "China Travel", "Picurl": "Http://zxpic. gtimg.com/infonew/0/wechat_pics_-4218551.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MzA5MzQyMzQyMw==&am            P;idx=3&mid=402488438&sn=88f2d7e415e6d18dafccaa8da549edb6 "}, {" CTime ":" 2016-03-31 ", "title": "When we are old, we go to run such a shop", "description": "Slow Time", "Picurl": "Http://zxpic.gtimg.com/infone w/0/wechat_pics_-4225311.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MjM5NTIxNTU0MA==&idx=1&mid=4  05728106&sn=b8ac94b83aa92eea54acf75eff89c657 "}, {" CTime ":" 2016-03-31 "," title ": "The exposure of unemployed women to the average monthly income, why is this?" "," description ":" Those who pass by the heart sentence "," Picurl ":" http://zxpic.gtimg.com/infonew/0/wechat_pics_-4116605.jpg/ 640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MjM5MTg3OTAzNg==&idx=1&mid=402804635&sn=172aa8f7bf0f8 078ade644f46722c561 "}, {" CTime ":" 2016-03-31 "," title ":" What people live in a single world? "          ",  "description": "Today's Literature", "Picurl": "http://zxpic.gtimg.com/infonew/0/wechat_pics_-4082011.jpg/640", "url": "Http://mp.weixin.qq.com/s?__biz=MjM5ODQxODMyMQ==&idx=1&mid=420440897&sn= cb4b009440b6a9d954bff2a622344e8d "}, {" CTime ":" 2016-03-31 "," title ":" These things, enough to make us believe in love. "             , "description": "Schoolgirl Psychology", "Picurl": "http://zxpic.gtimg.com/infonew/0/wechat_pics_-4225315.jpg/640", "url": "http://mp.weixin.qq.com/s?__biz=MzA3NjM5NDIyMw==&idx=1&mid=401870610&sn=1baf92ad1bb1b9f575 027473754551f9 "}, {" CTime ":" 2016-03-31 "," title ":" Young ladies, why do you always love to turn your eyes? "             "," description ":" Youth Digest "," Picurl ":" http://zxpic.gtimg.com/infonew/0/wechat_pics_-4225320.jpg/640 ", "url": "Http://mp.weixin.qq.com/s?__biz=MzA5ODEzMTIxOA==&idx=4&mid=405169046&sn=8ea51ec94fcd5d9bed   6d1df0d0bf889f "}, {" CTime ":" 2016-03-31 ",         "title": "Always say that Korean artists come to China to catch gold, first read these again," "description": "Runningman", "Picurl": "Http://zxpic.gtimg . com/infonew/0/wechat_pics_-4225344.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MzA3NDcwNzUxMw==&idx=            4&mid=403101020&sn=5a9fa497df693b768637faf85f2b6449 "}, {" CTime ":" 2016-03-31 ", "title": "Song Joong ki ShK avalanche scandals gossip song Joong Ki quite Enjoy", "description": "Korea New Net", "Picurl": "http://zxpic.gtimg.com/infonew/0/ wechat_pics_-4225352.jpg/640 "," url ":" http://mp.weixin.qq.com/s?__biz=MjM5MDAzNjYwMA==&idx=4&mid=40361 7618&sn=3446bb057607d2daf2e3123f837fa24d "}]}

How do you put the returned content and images on the web? Ask the big God answer, I rookie

Reply content:

API store's top featured API

 interface Address: Http://apis.baidu.com/txapi/weixin/wxhot Request method: Get request parameter (header): Parameter name type required argument location description default value Apikeystrin G is the header API key your own Apikey request parameter (urlparam): Parameter name type required parameter location description default value Numnumber is Urlparam article return number Volume 10randnumber no urlparam random, 1 means random 1wordstring no Urlparam search keywords tomb grave Note pagenumber no Urlparam page, output number Volume following num parameter 1srcstring no Urlparam specified article source People's Daily request example: Curl sample PHP Sample Python sample Java sample C # example OBJECTC Example Swift Example 1!--? php2 $ch = Curl_init (); 3 $url = ' http://apis.baidu.com/txapi/weixin/wxhot?num=10&rand=1&word=%E7%9B%97%E5%A2%93%E7%AC%94%E8% Ae%b0&page=1&src=%e4%ba%ba%e6%b0%91%e6%97%a5%e6%8a%a5 '; 4 $header = Array (5 ' Apikey: Your own Apikey ', 6); 7//Tim Add Apikey to Header8 curl_setopt ($ch, Curlopt_httpheader, $header); 9 curl_setopt ($ch, Curlopt_returntransfer, 1); 10 Execute HTTP Requests curl_setopt ($ch, Curlopt_url, $url), $res = Curl_exec ($ch), 1314 var_dump (Json_decode ($res)); 15? -->
JSON return Example: {"Code": 200,//Return Status Code "MSG": "Success",//Return status message "Newslist": [{"CTime": "2016-0 3-31 ",//Article release time" title ":" Qihoo 360 announces adoption of privatization resolution ",//Text title" description ":" Internet Headline ",//Source and description" pic URL ":" http://t1.qpic.cn/mblogpic/f01a972dbcc1060fd456/2000 ",//article illustration, null as Default" URL ":" Http://mp.weixin.qq.com/s?__            Biz=mjm5otmyoda2ma==&idx=1&mid=402594468&sn=5cd644536b472a283cc1d3f5124a0cab "},//article URL { "CTime": "2016-03-31", "title": "Small business to make money 17 size of the business recommendation", "description": "The forefront of Entrepreneurship", "pic URL ":" http://zxpic.gtimg.com/infonew/0/wechat_pics_-4225297.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz= Mza3njgznduwmq==&idx=2&mid=401864059&sn=cfa082e38ba38c7e673b1ce0a075faee "}, {" CTime            ":" 2016-03-31 "," title ":" When the poor tour from the online community to the offline travel service providers turn around, start a business than forget the "big platform" This matter, "description": "China Travel", "Picurl": "Http://zxpic. gtimg.com/infonew/0/wechat_pics_-4218551.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MzA5MzQyMzQyMw==&am            P;idx=3&mid=402488438&sn=88f2d7e415e6d18dafccaa8da549edb6 "}, {" CTime ":" 2016-03-31 ", "title": "When we are old, we go to run such a shop", "description": "Slow Time", "Picurl": "Http://zxpic.gtimg.com/infone w/0/wechat_pics_-4225311.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MjM5NTIxNTU0MA==&idx=1&mid=4  05728106&sn=b8ac94b83aa92eea54acf75eff89c657 "}, {" CTime ":" 2016-03-31 "," title ": "The exposure of unemployed women to the average monthly income, why is this?" "," description ":" Those who pass by the heart sentence "," Picurl ":" http://zxpic.gtimg.com/infonew/0/wechat_pics_-4116605.jpg/ 640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MjM5MTg3OTAzNg==&idx=1&mid=402804635&sn=172aa8f7bf0f8 078ade644f46722c561 "}, {" CTime ":" 2016-03-31 "," title ":" What people live in a single world? "          ",  "description": "Today's Literature", "Picurl": "http://zxpic.gtimg.com/infonew/0/wechat_pics_-4082011.jpg/640", "url": "Http://mp.weixin.qq.com/s?__biz=MjM5ODQxODMyMQ==&idx=1&mid=420440897&sn= cb4b009440b6a9d954bff2a622344e8d "}, {" CTime ":" 2016-03-31 "," title ":" These things, enough to make us believe in love. "             , "description": "Schoolgirl Psychology", "Picurl": "http://zxpic.gtimg.com/infonew/0/wechat_pics_-4225315.jpg/640", "url": "http://mp.weixin.qq.com/s?__biz=MzA3NjM5NDIyMw==&idx=1&mid=401870610&sn=1baf92ad1bb1b9f575 027473754551f9 "}, {" CTime ":" 2016-03-31 "," title ":" Young ladies, why do you always love to turn your eyes? "             "," description ":" Youth Digest "," Picurl ":" http://zxpic.gtimg.com/infonew/0/wechat_pics_-4225320.jpg/640 ", "url": "Http://mp.weixin.qq.com/s?__biz=MzA5ODEzMTIxOA==&idx=4&mid=405169046&sn=8ea51ec94fcd5d9bed   6d1df0d0bf889f "}, {" CTime ":" 2016-03-31 ",         "title": "Always say that Korean artists come to China to catch gold, first read these again," "description": "Runningman", "Picurl": "Http://zxpic.gtimg . com/infonew/0/wechat_pics_-4225344.jpg/640 "," url ":" Http://mp.weixin.qq.com/s?__biz=MzA3NDcwNzUxMw==&idx=            4&mid=403101020&sn=5a9fa497df693b768637faf85f2b6449 "}, {" CTime ":" 2016-03-31 ", "title": "Song Joong ki ShK avalanche scandals gossip song Joong Ki quite Enjoy", "description": "Korea New Net", "Picurl": "http://zxpic.gtimg.com/infonew/0/ wechat_pics_-4225352.jpg/640 "," url ":" http://mp.weixin.qq.com/s?__biz=MjM5MDAzNjYwMA==&idx=4&mid=40361 7618&sn=3446bb057607d2daf2e3123f837fa24d "}]}

How do you put the returned content and images on the web? Ask the big God answer, I rookie

Just put in the corresponding tag inside it is OK ....

You need to know:

    1. How to send a request in your back-end language

    2. What is JSON, how to parse JSON using your backend language or JavaScript

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.