I'm trying to request a url but it fails and when I var dump the result of curl exec it returns false.
http://mydomain.com:8807/getstate/?zipcode=22311&field=statecode
In the browser I can access it and it returns the correct HTTP Content Body, Content Type is text/html.
If I change it to:
http://mydomain.com:8807/getstate/?zipcode=22311&field=state
Which is the same REST service except the parameter value is different, my curl stuff works fine. How could this be?
I'm not making multiple requests, I'm only doing one instance..
$url = 'http://mydomain.com:8807/getstate/?zipcode=22311&field=state';
Which is the same REST service except the parameter value is different, my curl stuff works fine. How could this be?
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
$request = curl_exec( $ch );
var_dump($request);
I'm pretty damn positive it's not a typo, can't think of a reason. It returns bool(false)
for the statecode but returns the right thing for state.
Update: Seems like the response headers are not proper - the browser is lenient and renders the page regardless of incorrect headers ( or lack thereof ).