AlexMax
AlexMax

Reputation: 1204

PHP: Curl can't grab a text-only page on my own site

I'm attempting to use curl inside php to grab a page from my own web server. The page is pretty simple, just has some plain text output. However, it returns 'null'. I can successfully retrieve other pages on other domains and on my own server with it. I can see it in the browser just fine, and I can grab it with command line wget just fine, it's just that when I try to grab that one particular page with curl, it simply comes up null. We can't use file_get_contents because our host has it disabled.

Why in the world would this be different behavior be happening?

Upvotes: 3

Views: 649

Answers (3)

AlexMax
AlexMax

Reputation: 1204

Found the issue. I was putting my url someplace that was not in curl_init(), and that place was truncating the query string. Once I moved it back to curl_init, it worked.

Upvotes: 2

Peter Lindqvist
Peter Lindqvist

Reputation: 10200

You should check the output of curl_error() and also take a look at your logfiles for the http server.

Upvotes: 1

poundifdef
poundifdef

Reputation: 19353

Try setting curl's user agent. Sometimes hosts will block "bots" by blocking things like wget or curl - but usually they do this just by examining the user agent.

Upvotes: 1

Related Questions