使用PHP解析需要用户登录的页面

时间:2012-06-23 08:50:19

标签: php parsing curl login

我试图使用php的Curl登录页面。&然后在登录后解析数据..我使用Curl发布了所有变量的值.. bt amnt能够登录页面..请帮助..

这是我的代码:

<?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 个答案:

答案 0 :(得分:1)

而不是

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

$fields = array(
    "wps.portlets.userid" => "xxxxxxxx",
    "password"            => "xxxxxxxx"
);
相关问题