开发者

Need help for the correct values in a HTTP post (I think)

So i've never worked with PHP or http posting or anything before, so please excuse me if i'm asking something dumb.

Heres a site so I can explain more accurately what I need.

http://nycserv.nyc.gov/NYCServWeb/NYCSERVMain

So I want to write something that will get the resultant page info as if I had hit the "go" button next to where it says "consumer fair violation". After doing a bunch of googling, I think i'm supposed to do HTTP posting, so i've been messing around with PHP and CURl. This is the code i've came up with, although I'm not sure what values i'm supposed to actually post.

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://nycserv.nyc.gov/NYCServWeb/NYCSERVMain");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
    'dcadropdownmenu.name' => 'javascript:consumerAffairsViolationsQuerySetup("GET_CONSUMER_AFFAIRS_VIOLATION_SEARCH_QUERY_SETUP")');

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

print $info;
print $output;
?>

I'm pretty sure i'm not supposed to be setting dvaddropdowmenu.name, but I dont know what I am supposed to be posting. Any help would be great.

UPDATE So I finally got it to work. The problem i'm having now is how to HTTP post again on the returning page from the original. What I mean, is I got it to return the HTML from the page as if I hit the Go button. Now I need to hit the search button on this returned page. I tried just changing the post variables and exec'ing again, but开发者_运维知识库 that didn't work. Any help?


It took some digging through the JavaScript to find it, but here's the form that's actually being submitted:

form name=​"NycservProtocolForm" method=​"POST" action=​"NYCSERVMain">​
    <center>​…​</center>​
    <!--    N Y C S E R V   P R O T O C O L    -->
    <input type=​"HIDDEN" name=​"ChannelType" value=​"ct/​Browser">​
    <input type=​"HIDDEN" name=​"RequestType" value=​"rt/​Business">​
    <input type=​"HIDDEN" name=​"SubSystemType" value=​"st/​Payments">​
    <input type=​"HIDDEN" name=​"AgencyType" value=​"at/​PVO">​
    <input type=​"HIDDEN" name=​"ServiceName" value=​"NONE">​
    <input type=​"HIDDEN" name=​"MethodName" value=​"NONE">​
    <input type=​"HIDDEN" name=​"PageID" value=​"NYCSERVHome">​
    <input type=​"HIDDEN" name=​"ParamCount" value=​"0">​
    <input type=​"HIDDEN" name=​"NycservRequest" value=​"EMPTY">​
    <input type=​"HIDDEN" name=​"SearchType" value=​"EMPTY">​
    <input type=​"HIDDEN" name=​"LinkType" value=​"EMPTY">​
</form>

Depending on how familiar with the form you are, you can decide how many of these arguments you send. But these are the variables you want to specify when you send your POST request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜