I'm trying to use laravel-wp-api to get the posts from a blog. When I use Postman with http://idareyou.ee/blog//wp-json/wp/v2/posts I get a 200 OK HTTP response and Postman shows the JSON result.
The following Laravel BlogController getPosts() method prints in the browser this Curl error:
{"error":{"message":"cURL error 6: Couldn't resolve host '\u003Cwp_location\u003E' (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)"},"results":[],"total":0,"pages":0}
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use WpApi; class BlogController extends Controller { public function getPosts() { $posts = WpApi::posts('http://idareyou.ee/blog//wp-json/wp/v2/posts'); echo json_encode($posts,true); //return view('pages.blog', ['active'=>'navBlog'])->with('posts', $posts ); } } Elsewhere in my app I am fetching successfully some pictures from Instagram API using the following. Do I need a similar 'fetchData' function in my BlogController?
function fetchData($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = curl_exec($ch); curl_close($ch); return $result; } $result = fetchData("https://api.instagram.com/v1/users/......."); $result = json_decode($result, true); $lastFive = array_slice($result['data'], 0, 5); // returns last 5 instagram pics Can anybody give me any tips on what I'm doing wrong?