php模拟http post传输数据

<?
include_once("inc/auth.inc.php");
include_once("inc/utility_all.php");
include_once("inc/utility_org.php");
include_once("inc/editor.php");
include_once("inc/utility_file.php");




$HTML_PAGE_TITLE = _("绑定统计云账号");
include_once("inc/header.inc.php");

$user_id=$_SESSION["LOGIN_USER_ID"];
$query="select * from user where user_id='$user_id' limit 1";
$curosr=exequery(TD::conn(),$query);
while($row=mysql_fetch_array($curosr)){
	$tongjiyun=$row["tongjiyun"];
	
	}
if($tongjiyun==""){
	header("Location:tongjibangding.php");
	exit;
	}
$zhanghao=$tongjiyun;
$zhanghaob=base64_encode($zhanghao);

echo $zhanghaob."<br>";
echo base64_encode($zhanghaob)."<br>";
$u111="http://6.16.237.40:8090/cwbase/WebFramework/loginSsoOA.aspx?token=".$zhanghaob;
echo $u111."<br>";
$url2="http://10.78.1.236:8090/cwbase/WebFramework/loginSsoOA.aspx?token=".$zhanghaob;//10.78.1.236
echo $url2."<br>";
//$fh= file_get_contents("http://6.16.237.40:8090/cwbase/WebFramework/loginSsoOA.aspx?token=".$zhanghaob);
//echo $fh;
echo "<hr>";
//$fh1= file_get_contents("http://6.16.237.34:99/general/kuaijiedenglu/tongjiyun.php?token=WTJWemFHaz0=");
//echo $fh1;
echo "<hr>";

$re=curlPost($url2,$data='');

echo $re;
$url3="http://6.16.237.40:8090".$re;
  header("Location:".$url3);


function curlPost($url,$data=array())
    {
		//echo "aaaa";
  		$ch = curl_init();
        $params[CURLOPT_URL] = $url;    //请求url地址
        $params[CURLOPT_HEADER] = FALSE; //是否返回响应头信息
        $params[CURLOPT_SSL_VERIFYPEER] = false;
        $params[CURLOPT_SSL_VERIFYHOST] = false;
        $params[CURLOPT_RETURNTRANSFER] = true; //是否将结果返回
        $params[CURLOPT_POST] = true;
        $params[CURLOPT_POSTFIELDS] = $data;
        curl_setopt_array($ch, $params); //传入curl参数
        $content = curl_exec($ch); //执行
        curl_close($ch); //关闭连接
      //  echo $content."4444";
    	return $content;
    
	}

exit;
$youxiang=$_REQUEST["youxiang"];
echo $youxiang;
	 $url1  = "http://mail.chinabdh.com/services/TurboWebService/exe";  
//$data = json_encode(array("webservice_password"=>"bdh666", "beanid"=>"web.ssologin","json_params"=>array("username"=>"wutianzhuo","domain"=>"chinabdh.com"))); 
//echo $data."<br>";

	  $post_data1=array();
	  $post_data1["webservice_password"]="bdh666";
	
	   $post_data1["beanid"]="web.ssologin";
	    $post_data1["json_params"]='{"username":"'.$youxiang.'","domain":"chinabdh.com"}';
	  $o1 = "";
	  foreach ( $post_data1 as $k => $v ) 
	  { 
		  $o1.= "$k=" . urlencode( $v ). "&" ;
	  }
	  $post_data1 = substr($o1,0,-1);
	  
	  $res1 =request_post($url1, $post_data1);       
	 print_r($res1);
	  // $re1=json_decode($res1,true);
	  // echo $res1->data;;
	  
	  
$mode1 = "/<ns:return>(.*)<\/ns:return>/is"; 
	preg_match_all($mode1,$res1,$matches1);//正则获取json
	echo "<hr>";
	//print_r($matches1);
 $re1=$matches1[0][0];
 echo "<hr>";
	echo $re1;
	$re0=str_replace("<ns:return>","",$re1);
	$re3=str_replace("</ns:return>","",$re0);
   $re2=json_decode($re3);
   echo "<hr>";
   print_r($re2);
	 $sessionid=$re2->data->sessionid;
	 $urla="http://mail.chinabdh.com/sso_access?sessionid=".$sessionid."&hideheader=0&hidemainmenu=0&moduleid=mail.list.inbox";
	  header("Location:".$urla);
	  
 //http://mail.chinabdh.com/sso_access?sessionid= twa1_1604068729480287&hideheader=0&hidemainmenu=0&moduleid=mail.list.inbox
 ?>

 <?
function request_post($url = '', $param = '') {
        if (empty($url) || empty($param)) {
            return false;
        }
        
        $postUrl = $url;
        $curlPost = $param;
        $ch = curl_init();//初始化curl
        curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
        curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
        curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
        curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
        $data = curl_exec($ch);//运行curl
        curl_close($ch);
        
        return $data;
    }
function object_array($array){
  if(is_object($array)){
    $array = (array)$array;
  }
  if(is_array($array)){
    foreach($array as $key=>$value){
      $array[$key] = object_array($value);
    }
  }
  return $array;
} 


function xmlToArray($xml){
    if (file_exists($xml)) {
        libxml_disable_entity_loader(false);
        $xml_string = simplexml_load_file($xml,'SimpleXMLElement', LIBXML_NOCDATA);
    }else{
        libxml_disable_entity_loader(true);
        $xml_string = simplexml_load_string($xml,'SimpleXMLElement', LIBXML_NOCDATA);
    }
    $result = json_decode(json_encode($xml_string),true);
    return $result;
}
	 ?>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hai7425

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值