PHP怎么通过URL访问,获得新的URL 【调用百度map】
程序员文章站
2022-05-13 20:10:46
...
PHP如何通过URL访问,获得新的URL 【调用百度地图】
我是想在手机微信上进行一段导航
当前导航的URL地址如果录入到IE地址栏中是能正常访问的:http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813|name:测试起点&destination=latlng:24.503361,118.139877|name:测试终点&mode=driving®ion=厦门&output=html
录入后,回车会发现地址变成了:
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
想知道如果用PHP如何实现 根据原来的URL,请求后得到新的URL?谢谢。
------解决方案--------------------
原來的url是http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813
------解决方案--------------------
name:测试起点&destination=latlng:24.503361,118.139877
------解决方案--------------------
name:测试终点&mode=driving®ion=厦门&output=html
新的url是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
用新的url就可以打開了,舊的不行,對嗎?
所以你想可以根據舊url獲取新url然後使用?
------解决方案--------------------
试试.
禁用的函数:
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
禁用的类:
SQLiteDatabase
SQLiteResult
SQLiteUnbuffered
SQLiteException
APCIterator
我是想在手机微信上进行一段导航
当前导航的URL地址如果录入到IE地址栏中是能正常访问的:http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813|name:测试起点&destination=latlng:24.503361,118.139877|name:测试终点&mode=driving®ion=厦门&output=html
录入后,回车会发现地址变成了:
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
想知道如果用PHP如何实现 根据原来的URL,请求后得到新的URL?谢谢。
------解决方案--------------------
原來的url是http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813
------解决方案--------------------
name:测试起点&destination=latlng:24.503361,118.139877
------解决方案--------------------
name:测试终点&mode=driving®ion=厦门&output=html
新的url是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
用新的url就可以打開了,舊的不行,對嗎?
所以你想可以根據舊url獲取新url然後使用?
------解决方案--------------------
试试.
$url = 'http://api.map.baidu.com/direction?origin=latlng:24.481428,118.124813
------解决方案--------------------
name:测试起点&destination=latlng:24.503361,118.139877
------解决方案--------------------
name:测试终点&mode=driving®ion=厦门&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 '';
}
禁用的函数:
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
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
禁用的类:
SQLiteDatabase
SQLiteResult
SQLiteUnbuffered
SQLiteException
APCIterator
相关文章
相关视频
上一篇: 两个例子理解PHP‘引用’
下一篇: 伪静态技术的相关内容推荐