PHP file_get_contents returning false

前端 未结 4 1851
南笙
南笙 2021-01-04 00:12

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

4条回答
  •  滥情空心
    2021-01-04 00:36

    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.

提交回复
热议问题