Maybe I've been sat here too long staring at this but WHY would file_get_contents
return false
here? I've cut and paste the URL and it works fine?
$url = "http://jobs.github.com/positions.json?search=" . $as_any . "&location=" . $location; // URL contains http://jobs.github.com/positions.json?search=Project Manager&location=London var_dump($url); $json = file_get_contents($url); var_dump($json); $results = json_decode($json, TRUE); var_dump($results); exit;
EDIT:
I have checked for allow_url_fopen
and its definitely on.
The function returns the read data or false on failure. This function may return Boolean false , but may also return a non-Boolean value which evaluates to false .
The file_get_contents() reads a file into a string. This function is the preferred way to read the contents of a file into a string. It will use memory mapping techniques, if this is supported by the server, to enhance performance.
file_get_contents() is slightly faster than cURL.
The file_get_contents() function reads entire file into a string. The file() function reads the entire file in a array, whereas file_get_contents() function reads the entire file into a string.
Try this:
$query = http_build_query(array('search'=>$as_any, 'location'=>$location)); $url = "http://jobs.github.com/positions.json?" . $query;
The problem is that you weren't URL-encoding the search term, which contains a space. The request was returning a 400 error from the server, which you'd have noticed if you had error reporting enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With