0

我试图使用 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);
?>
4

1 回答 1

1

代替

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

尝试

$fields = array(
    "wps.portlets.userid" => "xxxxxxxx",
    "password"            => "xxxxxxxx"
);
于 2012-06-23T08:55:41.550 回答