Reputation: 4490
I'm getting this error:
`file_get_contents(): stream does not support seeking
I have no clue to fix it. There is no Resource Id or whatsoever.
This is my code:
$postData = array('name' => $name, 'description' => $description, 'date_begin' => $start, 'date_end' => $end);
$stream = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n"
. "Authorization: Basic Y3Nub2VrOnNuMDNr\r\n",
'method' => 'POST',
'content' => http_build_query($postData)
)
);
return stream_context_create($stream);
And in the file where the stream returns to. Its the function getApiContext
.
$responseJson = json_decode(file_get_contents('http://10.0.0.89/api/v1/projects', false, BaseController::getApiContext(), true));
And then I get this annoying error. I know about cUrl, but I must use streams.
Upvotes: 0
Views: 4836
Reputation: 6822
It seems you are passing the fourth parameter to file_get_contents, this is not supported for remote streams (as per the documentation: https://www.php.net/manual/en/function.file-get-contents.php)
Change your call to file_get_contents to exclude it (or pass it to json_decode if that was your intent).
$responseJson = json_decode(file_get_contents('http://10.0.0.89/api/v1/projects', false, BaseController::getApiContext()));
Upvotes: 1
Reputation: 1760
why have you got true
on your file_get_contents
offset param? perhaps you meant to put this in the json_decode
if so, try this:
$responseJson = json_decode(file_get_contents('http://10.0.0.89/api/v1/projects', false, BaseController::getApiContext()),true);
Upvotes: 2