PHP file_get_contents问题

I am having a problem with PHP's file_get_contents command.

$url = "http://api.rememberthemilk.com/services/rest/".$format.$auth_token.$filter."&api_sig=".$md5.$apikey.$method;

$content = file_get_contents($url);

$array = json_decode($content, true);
$taskname = $array['rsp']['tasks']['list']['taskseries']['name'];
$duedate = $array['rsp']['tasks']['list']['taskseries']['task']['due'];

($format, $auth_token, $filter, $md5, $apikey, $method are already defined in the script)

When I try to run this code this error is returned:

[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad request for line 101

line 101 = $content, = file_get_contents($url);

How to fix this? Thanks!!!

Try printing the URL after concatenating the variables. Then paste the URL into the address bar of your browser and see what comes back. Because it's a web service call, your browser might not know what to do with the response. In that case you might get additional information using the command-line user agent "curl", e.g.

curl -v 'http://some-url'

curl is built in to Macs and other *nix machines and is also available for Windows.

This url does not look great.

http://api.rememberthemilk.com/services/rest/?format=json&auth_token=AUTH_TOKEN&­filter=dueWithin:"3 days of today"&api_sig=API_SIG&api_key=API_KEY&method=rtm.tasks.getList

Encode the tokens as follows:

$filter = 'filter='.urlencode( 'dueWithin:"3 days of today"' );

Use urlencode().