php - json_decode renders The Response content must be a string or object implementing __toString() -


i use laravel , function json_decode. amongst others, use within popular module , doesn't work there on in own, simple testcase. seem have todo setup/settings. (i'm running on pagodabox , locally). data feed twitter/instagram, content json.

here example of doesn't work:

<?php  class instagramcontroller extends basecontroller {      /*     |--------------------------------------------------------------------------     | default home controller     |--------------------------------------------------------------------------     |     | may wish use controllers instead of, or in addition to, closure     | based routes. that's great! here example controller method     | started. route controller, add route:     |     |   route::get('/', 'homecontroller@showwelcome');     |     */      public function read($q)     {         $client_id = '#############';          $uri = 'https://api.instagram.com/v1/tags/'.$q.'/media/recent?client_id='.$client_id;         $response = $this->sendrequest($uri);          return json_decode($response);     }      public function sendrequest($uri){         $curl = curl_init($uri);         curl_setopt($curl, curlopt_returntransfer, true);         curl_setopt($curl, curlopt_ssl_verifypeer, 0);         curl_setopt($curl, curlopt_ssl_verifyhost, 0);         $response = curl_exec($curl);         curl_close($curl);         return $response;     }  } 


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -