Decoding json in twitter using Eliiot Twitter For Codeigniter
Currently Im trying to use elliot
s twitter library for CI at http://www.haughin.com/code/twitter/ after installation, it went well. the source code worked well..
Then I try to add code at index() function which is like this :
function index()
{
echo 'hi there';
$user = $this->tweet->call('get', 'acco开发者_StackOverflow中文版unt/verify_credentials');
$dec = json_decode($user);
}
I tried to decode json by using json_decode() function but it return error
json_decode() expects parameter 1 to be string, object given
This is my first time working with json.. Is there something I missed out ? Thank you..
You should juggling that object into string type...
$user = (string) $this->tweet->call('get', 'account/verify_credentials');
$dec = json_decode($user);
It doesn`t need any variable convertion. just access object directly like $dec->username
精彩评论