代码之家  ›  专栏  ›  技术社区  ›  ariefbayu

twitteroauth:类stdclass的对象无法转换为字符串

  •  0
  • ariefbayu  · 技术社区  · 15 年前

    我有以下代码(取自实际脚本):

    $result=mysql_query($sql);
    while($row=mysql_fetch_assoc($result))
    {
     $auth_token=$row['oauth_token'];
     $auth_token_secret=$row['oauth_token_secret'];
     $apiconn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $auth_token, $auth_token_secret);
    
     $API_result = $apiconn->post('friendships/create', array('screen_name' => $uname));
     echo $API_result . "<br />";
    
    }
    

    我不断出错:

    Catchable fatal error: Object of class stdClass could not be converted to string in scriptpath on line 26
    

    第26行是

    $apiconn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $auth_token, $auth_token_secret);
    

    我不知道为什么会这样,因为 that library 在不产生错误的情况下执行相同的操作:(。

    1 回复  |  直到 15 年前
        1
  •  1
  •   46bit    15 年前

    试着去做 var_dump($API_result) 而不是重复它,看看你如何得到你真正想要的。我认为这只是另一个关于给出第26行的PHP计数错误的例子(可能与不同的操作系统行尾有关,尽管我不确定)。

    推荐文章