在Twitter上使用Eliiot Twitter解码json对于Codeigniter

在Twitter上使用Eliiot Twitter解码json对于Codeigniter

问题描述:

目前我的m trying to use elliot s安装后的CI为http://www.haughin.com/code/twitter/的twitter库很好。源代码工作以及..在Twitter上使用Eliiot Twitter解码json对于Codeigniter

然后我尝试在索引中添加代码()函数,它是这样的:

function index() 
     { 
      echo 'hi there'; 

      $user = $this->tweet->call('get', 'account/verify_credentials'); 

      $dec = json_decode($user); 
     } 

我尝试用json_decode()函数来解码JSON,但它返回错误

json_decode() expects parameter 1 to be string, object given 

这是我第一次使用json .. 有什么我错过了吗? 谢谢。

它不`吨需要的任何变量皈依。 只是直接访问对象像$ dec->用户名

你应该杂耍该对象转换为字符串类型...

$user = (string) $this->tweet->call('get', 'account/verify_credentials'); 
$dec = json_decode($user); 
+0

它给我错误类stdClass的对象无法转换为字符串 – justmyfreak

+0

你转储该var,什么包含? – toopay

+0

dump_var工作正常,但它直接打印输出。 – justmyfreak