How to access php via URL, get a new URL "call Baidu map"

Source: Internet
Author: User
How to access php via URL, get a new URL "call Baidu map"
I'm trying to do a little navigation on my phone.
The URL address of the current navigation can be accessed normally if it is entered into the IE Address bar: http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813|name: Test start &destination=latlng:24.503361,118.139877|name: Test End &mode=driving&region= Xiamen &output=html

After inputting, the carriage return will find that the address becomes:
http://map.baidu.com/?l=&s=nav%26sn%3D1%24%24%24%2413149737.11%2C2794316.21%24%24%E6%B5%8B%E8%AF%95%E8%B5% B7%e7%82%b9%24%24%24%24%24%24%26en%3d1%24%24%24%2413151414.05%2c2796984.18%24%24%e6%b5%8b%e8%af%95%e7%bb%88%e7 %82%b9%24%24%24%24%24%24%26sc%3d194%26ec%3d194

Want to know how to use PHP to implement the original URL, the request after the new URL? Thank you.






------Solution--------------------
The original URL is http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813
------Solution--------------------
Name: Test start &destination=latlng:24.503361,118.139877
------Solution--------------------
Name: Test End &mode=driving&region= Xiamen &output=html

The new URL is http://map.baidu.com/?l=&s=nav%26sn%3D1%24%24%24%2413149737.11%2C2794316.21%24%24%E6%B5%8B%E8%AF%95% E8%b5%b7%e7%82%b9%24%24%24%24%24%24%26en%3d1%24%24%24%2413151414.05%2c2796984.18%24%24%e6%b5%8b%e8%af%95%e7%bb %88%e7%82%b9%24%24%24%24%24%24%26sc%3d194%26ec%3d194

With the new URL can be opened, old not, right?

So you think you can get a new URL from the old URL and then use it?
------Solution--------------------
Give it a try.

$url = ' http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813
------Solution--------------------
Name: Test start &destination=latlng:24.503361,118.139877
------Solution--------------------
Name: Test End &mode=driving&region= Xiamen &output=html ';
$newurl = Getmapurl ($url);
Echo $newurl;

function Getmapurl ($url) {
File_get_contents ($url);
$result = $http _response_header;
if ($result) {
foreach ($result as $val) {
if (substr ($val, 0,10) = = ' Location: ') {
return Str_replace (' Location: ', ', $val);
}
}
}
Return ';
}


Functions that are disabled:

Php_real_logo_guid
Php_egg_logo_guid
Readlink
LinkInfo
Symlink
Link
Set_file_buffer
Exec
System
Escapeshellcmd
Escapeshellarg
PassThru
Shell_exec
Proc_open
Proc_close
Proc_terminate
Proc_get_status
Proc_nice
Getmyuid
Getmygid
Getmyinode
Putenv
Getopt
Sys_getloadavg
Getrusage
Get_current_user
Magic_quotes_runtime
Set_magic_quotes_runtime
Import_request_variables
Debug_zval_dump
Ini_alter
Dl
Pclose
Popen
Stream_socket_client
Stream_socket_server
Stream_socket_accept
Stream_socket_pair
Stream_get_transports
Stream_wrapper_restore
Get_headers
Mail
Mb_send_mail
Openlog
Syslog
Closelog
Apc_add
Apc_bin_dump
Apc_bin_dumpfile
Apc_bin_load
Apc_bin_loadfile
Apc_cache_info
Apc_cas
Apc_clear_cache
Apc_compile_file
Apc_dec
Apc_define_constants
Apc_delete_file
Apc_delete
Apc_exists
Apc_fetch
Apc_inc
Apc_load_constants
Apc_sma_info
Apc_store
Flock
Pfsockopen
Posix_kill
Apache_child_terminate
Apache_get_modules
Apache_get_version
Apache_getenv
Apache_lookup_uri
Apache_reset_timeout
Apache_response_headers
Apache_setenv
Virtual
Mysql_pconnect
Socket_create
Socket_create_pair
Classes that are disabled:

Sqlitedatabase
Sqliteresult
Sqliteunbuffered
Sqliteexception
Apciterator
  • 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.