REST API error
-
Hi,
I have a PHP script which calls the REST API through get_file_content (),
This is the script
$context = stream_context_create( array( "http" => array( "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36" ) ) ); $uri="http://mysite.com/wp-json/tribe/events/v1/events?page=1&per_page=50&start_date=2000-01-01" ; $json = file_get_contents($uri,false, $context); $posts= json_decode($json);I call the script from the following url
http://mysite.com/myscript.php
Show me a error
Warning: file_get_contents(http://mysite.com/wp-json/tribe/events/v1/events?page=1&per_page=50&start_date=2000-01-01): failed to open stream: HTTP request failed! in myscript.php on line 12
But if I put url in a browser
http://mysite.com/wp-json/tribe/events/v1/events?page=1&per_page=50&start_date=2000-01-01
Browser shows me results.
Why the script gives me an error ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘REST API error’ is closed to new replies.