Twitteroauth:类STDClass的对象无法转换为字符串
-
04-10-2019 - |
题
我有以下代码(取自实际脚本):
$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);
我不知道为什么会发生这种情况,因为 那个库 在没有产生错误的情况下进行操作:(。
解决方案
尝试做 var_dump($API_result)
而不是回荡它,看看您如何获得实际想要的东西。我认为这只是给出第26行(大概与不同的OS线路结尾有关的事情,尽管我不确定)的另一个示例是错误的。
不隶属于 StackOverflow