2012-06-23 34 views
0

我试图登录到一个页面使用PHP的卷曲.. &然后解析登录后的数据..我张贴所有变量的值使用curl .. bt amnt able登录到网页..请帮助..解析一个页面,需要用户登录使用PHP

这里是我的代码:

<?php 
$fields_string=array(); 
$url = '`http://data.bsnl.in/wps/portal/!ut/p/c5/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hnd0cPE3!MfAwMLFzcLAyMnUzPPQAMXAwNfM_1wkA6zeAMcwNFA388jPzdVP1I_yhynOa4G-iH6kU76Bdl55QaOiooAzstUAA!!/dl3/d3/L2dBISEvZ0FBIS9nQSEh/`'; 

$fields = array(
      "userID"=>"xxxxxxxx", 
    "password"=>"xxxxxxx" 
     ); 

//url-ify the data for the POST 
foreach($fields as $key=>$value) 
{ 
$fields_string .= $key.'='.$value.'&'; 
} 
rtrim($fields_string,'&'); 

//open connection 
$ch = curl_init(); 

//set the url, number of POST vars, POST data 
curl_setopt($ch,CURLOPT_URL,$url); 
curl_setopt($ch,CURLOPT_POST,count($fields)); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields); 

//execute post 
$result = curl_exec($ch); 
echo $result; 

//close connection 
curl_close($ch); 
?> 
+1

为什么你的网址中有引号? – slash197

回答

1

而不是

$fields = array(
    "userID" => "xxxxxxxx", 
    "password" => "xxxxxxxx" 
); 

尝试

$fields = array(
    "wps.portlets.userid" => "xxxxxxxx", 
    "password"   => "xxxxxxxx" 
); 
+0

正确。另外,接受会话cookie可能是明智的做法。 –

相关问题