PHP如何通过URL访问,获得新的URL 【调用百度地图】 百度地图微信urlphp导航 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 转码的原因是 上面带中文的,我发现微信里,IPHONE导航页面打不开,是空白的。但是如果通过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产生新的URL。多谢啊。 <?php$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){ $result = get_headers($url, true); return isset($result['Location'])? $result['Location'] : '';}?> 兄弟,感谢回复。不过我用的是新浪SAE,里面提示我:Warning: get_headers() has been disabled for security reasons in test.php on line 7get_headers() 还能有别的办法替换么?谢谢。 试试.$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_guidphp_egg_logo_guidreadlinklinkinfosymlinklinkset_file_bufferexecsystemescapeshellcmdescapeshellargpassthrushell_execproc_openproc_closeproc_terminateproc_get_statusproc_nicegetmyuidgetmygidgetmyinodeputenvgetoptsys_getloadavggetrusageget_current_usermagic_quotes_runtimeset_magic_quotes_runtimeimport_request_variablesdebug_zval_dumpini_alterdlpclosepopenstream_socket_clientstream_socket_serverstream_socket_acceptstream_socket_pairstream_get_transportsstream_wrapper_restoreget_headersmailmb_send_mailopenlogsyslogcloselogapc_addapc_bin_dumpapc_bin_dumpfileapc_bin_loadapc_bin_loadfileapc_cache_infoapc_casapc_clear_cacheapc_compile_fileapc_decapc_define_constantsapc_delete_fileapc_deleteapc_existsapc_fetchapc_incapc_load_constantsapc_sma_infoapc_storeflockpfsockopenposix_killapache_child_terminateapache_get_modulesapache_get_versionapache_getenvapache_lookup_uriapache_reset_timeoutapache_response_headersapache_setenvvirtualmysql_pconnectsocket_createsocket_create_pair禁用的类:SQLiteDatabaseSQLiteResultSQLiteUnbufferedSQLiteExceptionAPCIterator 兄弟,给力啊。100分都给你了。结贴,哈。谢谢。看的晚了,还找了一个,顺便分享。private function getHeadersNew($url){ $ch= curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $f=curl_exec($ch); curl_close($ch); $h=explode("\n",$f); $r=array(); foreach( $h as $t){ $rr=explode(":",$t,2); if(count($rr)==2 ){ $r[$rr[0]]=trim($rr[1]);} } return $r; } 如何防止刷新 急,100分求救 php输出文件是否有大小限制 PHP cookie 和session 有什么区别,可说详细点, PHP中的 @ 是做什么的? 上传文件问题。。。 求助 php4运行在php5上的问题 请教:哪里可以找到一个功能强大的日期时间计算类? Eclipsephp 3中调试时如何将工作目录下的项目自动更新发布到APACHE上面 一直没搞懂(substr($info[tupian],6,(strlen($info[tupian])-6)));作用是什么? 商城类网站的商品图片是怎样显示的 dreamweaver制作PHP网页,如何将表单提交给跳转菜单即将跳转的页面
但是如果通过URL请求后,得到的新URL,配置在微信里是可以正常打开百度地图的。所以我想写一个函数来处理这个,求教高手,谢谢。
兄弟,是这个意思。我就像 用旧的URL产生新的URL。
多谢啊。
<?php$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){
$result = get_headers($url, true);
return isset($result['Location'])? $result['Location'] : '';
}?>
兄弟,感谢回复。
不过我用的是新浪SAE,里面提示我:
Warning: get_headers() has been disabled for security reasons in test.php on line 7
get_headers() 还能有别的办法替换么?谢谢。
$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
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
谢谢。看的晚了,还找了一个,顺便分享。private function getHeadersNew($url){
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$f=curl_exec($ch);
curl_close($ch);
$h=explode("\n",$f);
$r=array();
foreach( $h as $t){
$rr=explode(":",$t,2);
if(count($rr)==2 ){ $r[$rr[0]]=trim($rr[1]);}
}
return $r;
}