This is my PHP code: (name of the file is getname.php)
<?php
$query = $_GET['p']; //supplied as getname.php?p=easy+is+his+name
$link = 'http://api.genius.com/search?access_token=MY_ACCESS_TOKEN&q='.$query;
$json = file_get_contents($link);
$obj = json_decode($json);
echo $obj->response->hits[0]->result->title;
?>
When I'm running this code, the error is like,
file_get_contents(http://api.genius.com/search?access_token=MY_ACCESS_TOKEN&q=easy is his name): failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported -- at line 5
And when I write the code as,
<?php
$link = 'http://api.genius.com/search?access_token=MY_ACCESS_TOKEN&q=easy+is+his+name';
$json = file_get_contents($link);
$obj = json_decode($json);
echo $obj->response->hits[0]->result->title;
?>
, the expected results are shown. Why is it so?