2012-06-23 31 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可能是明智的做法。 –

相關問題