|
在php页面中,采用如下方式访问baas(java)后台,后台总是拿不到参数,请问该如何传参:[注:如果不传参数可以成功访问]
- $post_data = array () ;
- $post_data [ ' clientname ' ] = " test08 " ;
- $post_data [ ' clientpasswd ' ] = " test08 " ;
- $post_data [ ' submit ' ] = " submit " ;
- $url = ' <a href="http://xxx.xxx.xxx.xx/xx/xxx/top.php" target="_blank">http://xxx.xxx.xxx.xx/baas/jf/Mlinterface/doAction</a> ' ;
- $o = "" ;
- foreach ( $post_data as $k => $v )
- {
- $o .= " $k = " . urlencode ( $v ) . " & " ;
- }
- $post_data = substr ( $o , 0 ,- 1 ) ;
- $ch = curl_init () ;
- curl_setopt ( $ch , CURLOPT_POST , 1 ) ;
- curl_setopt ( $ch , CURLOPT_HEADER , 0 ) ;
- curl_setopt ( $ch , CURLOPT_URL , $url ) ;
- //为了支持cookie
- curl_setopt ( $ch , CURLOPT_COOKIEJAR , ' cookie.txt ' ) ;
- curl_setopt ( $ch , CURLOPT_POSTFIELDS , $post_data ) ;
- $result = curl_exec ( $ch ) ;
复制代码
|
|