twittoris Posted April 28, 2010 Share Posted April 28, 2010 I am trying to grab the contents from a form result. However, I keep getting the following message. Warning: file_get_contents(http://a836-acris.nyc.gov/docsearch.dll/BBL) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 405 Method not allowed in /home/content/e/m/p/empireestate/html/acris.php on line 23 This is my first draft so i know its not working but was wondering if someone can give me a few pointers. Quote Link to comment Share on other sites More sharing options...
twittoris Posted April 28, 2010 Author Share Posted April 28, 2010 Forgot to attach the code: <?php $URL = 'http://a836-acris.nyc.gov/Scripts/DocSearch.dll/BBL'; $postdata = http_build_query( array( 'hid_borough' => '1', 'hid_block' => '995', 'hid_lot' => '1', ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://a836-acris.nyc.gov/docsearch.dll/BBL', false, $context); ?> Quote Link to comment Share on other sites More sharing options...
twittoris Posted April 28, 2010 Author Share Posted April 28, 2010 Now I changed to cURL and recieve HTTP 405 - Resource not allowed Anyone? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 28, 2010 Share Posted April 28, 2010 what is the code for your curl Quote Link to comment Share on other sites More sharing options...
twittoris Posted April 28, 2010 Author Share Posted April 28, 2010 $post_fields = array( 'g.hid_borough.value' => $_POST['1'], 'g.hid_block.value ' => $_POST['995'], 'g.hid_lot.value ' => $_POST['1'], ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://a836-acris.nyc.gov/Scripts/DocSearch.dll/BBLResult'); // set the remote url curl_setopt($ch, CURLOPT_POST, 1); // yes we are posting curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); // this is our POST data curl_setopt($ch, CURLOPT_HEADER, 0); // no headers in output curl_setopt($ch, CURLOPT_VERBOSE, 1); // verbose output, good for debugging curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// $ch will return the results of your POST when you execute curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); // the remote sites often check for a known user agent $result = curl_exec ($ch); curl_close($ch); echo($ch); print $result ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 28, 2010 Share Posted April 28, 2010 i did some error checking with CURL i get the following The requested URL returned error: 405 Quote Link to comment Share on other sites More sharing options...
twittoris Posted April 29, 2010 Author Share Posted April 29, 2010 Yeah I know. I dont know what that means. I think it is a validation error. Or maybe my form names are wrong but i dont know how to figure out the hidden form values from the BBL.js file it is passed on too. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 29, 2010 Share Posted April 29, 2010 whats the content os the js file? Quote Link to comment Share on other sites More sharing options...
twittoris Posted April 29, 2010 Author Share Posted April 29, 2010 http://a836-acris.nyc.gov/docsearch/js/BBL.js Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 29, 2010 Share Posted April 29, 2010 they are rewriting certain directories so they are not accessible. i do not think you will be able to find a way around it sorry. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.