tags:

views:

34

answers:

1

Here is a snippet of my code:

include("JSON.php");
$json = new Services_JSON();
$value=array('jsonrpc'=>'2.0', 'method'=>'methodname', 'params'=>array('param1',"param2"),'id'=>1);
$output = $json->encode($value);
print($output);

$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept: application/json\r\n"."Content-type: application/json-rpc\r\n"."Content-Length:1000\r\n"  ,
 'user_agent'    => 'spider',
 'content'=>$output
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('link', false, $context);

print($file);
 $value = $json->decode($file);
?>

But I get this error:

[function.file-get-contents]: failed to open stream: HTTP request failed

I have tried seeing the settings in php.ini file, everyhting seems fine. I tried file_get_contents('www.google.com') and it worked.

A: 

If this is the code you are calling:

$file = file_get_contents('link', false, $context);

Then PHP is trying to find "link" as a file. When it does not, it fails. That would be the only logical problem I see.

By the way, PHP includes json_encode/json_decode

Colum