0

我正在尝试将 post 参数发送到 url http://judis.nic.in/supremecourt/DateQry.aspx

并在 php 中阅读响应...如何发送和阅读响应...!

提前致谢..

我的代码...如下评论

<?php

 $ch = curl_init();


 curl_setopt($ch, CURLOPT_URL, "http://judis.nic.in/supremecourt/DateQry.aspx");
 curl_setopt($ch, CURLOPT_HEADER, 0);


 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, "button=Submit");
 curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlday1=01");
 curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlday2=31");
 curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlmonth1=01");
  curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlmonth2=01");
 curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlreport=A");
curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlyear1=2013");
curl_setopt($ch, CURLOPT_POSTFIELDS, "ddlyear2=2013");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 

$response=curl_exec($ch); 
echo $response; 
curl_close($ch);
?>
4

1 回答 1

0

通过利用cURL

这是一个例子

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://judis.nic.in/supremecourt/DateQry.aspx");
curl_setopt($ch, CURLOPT_HEADER, 0);

// say if your URL has any POST params
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=John");


// grab URL and pass it to the browser
$response=curl_exec($ch);

//Display your response
echo $response;

// close cURL resource, and free up system resources
curl_close($ch);
?>

编辑:

像这样连接字段

//Since you are using multiple fields .. do like this 
$postFields="button=Submit&ddlday=01&ddlday2=31&ddlmonth1=01&ddlmonth2=01&ddlreport=A&ddlyear1=2013&ddlyear2=2013";
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
于 2013-10-30T06:32:18.723 回答