WeChat public platform development-public transit transfer

Source: Internet
Author: User
Public platform development-public transit transfer 1) API application

2) API call



3) [B] effect Display [/B]

4) precise query

--------------------------------------------------------------------------

1) API application

Love to provide query interface API, need to apply for Key http://www.aibang.com

There is a limit on the number of queries, 1000 to times per day/10 times per minute

Return json data

Data Description

Provides demo files

2) API call

After you call the API to obtain data, you can output the data in your own format.

/* Aibang's api return josn data d_eng (sh109419@163.com) 2013-12-4 */define ("APP_KEY", "xx00ac1_d6d75e8681fc8380060c5b2"); include_once "ABClient. php "; // header (" Content-Type: text/html; charset = utf-8 "); function bustransfer ($ city, $ start, $ end) {$ client = new ABClient (APP_KEY); list ($ code, $ arr) = $ client-> getBusTransfer ($ city, array ("start_addr" => $ start, "end_addr" => $ end); if ($ code <> 200) {return false;} $ ret = ""; $ buses = $ arr [buses] [bus]; // show the top 3 records $ ret = $ start. "--> ". $ end. "\ n"; $ count = 1; foreach ($ buses as $ bus) {if ($ count> 3) break; $ segments = $ bus [segments] [segment]; $ ret. ="
 <方案".$count++.">
  
\ N "; // get line name and remove remark $ linename =" "; foreach ($ segments as $ segment) {if (! Empty ($ linename) $ linename. = '--'; $ linename. = shortlinename ($ segment [line_name]);} $ ret. = $ linename. "\ n"; $ total = sprintf ("% d min % d M walk % d M", $ bus [time], $ bus [dist], $ bus [foot_dist]); $ ret. = $ total. "\ n"; // detail $ from = sprintf ("from % s", $ start); $ ret. = $ from; foreach ($ segments as $ segment) {if ($ segment [foot_dist]> 0) {$ segfoot = sprintf ("% d walk to % s ", $ segment [foot_dist], $ segment [start_stat]); $ ret. = $ segfoot. "\ n" ;}$ stats = substr_count ($ segment [stats], ';'); $ line = sprintf ("Ride % s (% d station) % s ", shortlinename ($ segment [line_name]), $ stats, $ segment [end_stat]); $ ret. = $ line. "\ n";} if ($ bus [last_foot_dist]> 0) {$ lastfoot = sprintf ("Walk % d meters to % s", $ bus [last_foot_dist], $ end); $ ret. = $ lastfoot;} return $ ret;} function calls linename ($ linename) {return substr ($ linename, 0, strpos ($ linename ,'('));} $ a = bustransfer ("Nanchang", "laofushan", "Qingshan intersection"); var_dump ($ );
 

3) effect display

In this way, the chance of finding a bus transfer is increased.

The above is the public platform development-public transit transfer content. For more information, please follow the PHP Chinese network (www.php.cn )!

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.