0

I want to fetch values from a url along with some parameters.I use the following code

$ch = curl_init("http://www.xzxxz.ca/api/Listing.svc/PropertySearch_Post?ApplicationId=1&BathRange=0-0&BedRange=0-0&CultureId=1&CurrentPage=1&LatitudeMax=60.500524687194485&LatitudeMin=56.46248967233933&LongitudeMax=-27.4658203125&LongitudeMin=-145.5029296875&MaximumResults=9&ParkingSpaceRange=0-0&PriceMax=0&PriceMin=0&PropertyTypeId=300&RecordsPerPage=9&SortBy=1&SortOrder=A&TransactionTypeId=2&viewState=m&cookiecheck=1");
$fp = fopen("collected.txt", "w");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FILE, $fp);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

while using this code '405 - HTTP verb used to access this page is not allowed.' is shown.Is this due to the .svc file format or mistake in parameters passing?

4
  • If you copy and paste the URL directly into a web browser, do you get the same error or does it work? Commented Jan 1, 2015 at 12:30
  • while pasting the URL in the web browser the same error is displayed. Commented Jan 2, 2015 at 3:15
  • This is not data-mining (no statistical analysis happening here). It's not even web-scraping yet, but curl and http, actually. (You are doing a POST, the web site only allows a GET) Commented Jan 2, 2015 at 8:59
  • Is there option to fetch vvalues from this URL? Commented Jan 5, 2015 at 3:34

1 Answer 1

1

It sounds like the remote web server is refusing the connection because you are trying to POST data to it.

Try removing the following line...

curl_setopt($ch, CURLOPT_POST, 1);

This should change the HTTP method from POST to GET.

Sign up to request clarification or add additional context in comments.

1 Comment

It sounds like your problem is most likely something to do the the server your posting to and not your PHP code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.