【问题标题】:PHP - Access twitter api response variablesPHP - 访问 twitter api 响应变量
【发布时间】:2016-06-03 19:51:31
【问题描述】:

我正在使用 twitter api 来获取我的最新提及。

Twitter api 链接:https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline

用于获取最后提及的函数:

function twitter_get_tweets(){
    $connection = $this->twitter_auth();
    $latest_tweet = $connection->get('statuses/mentions_timeline', array('count' => 1));
    return $latest_tweet;
}

回复预览:http://projects.helpful.ninja/twitter/

遗憾的是我无法直接访问其中的变量,例如文本节点。

例子:

[text] => @pr0b_ Submit a request to our Support team and they'll be in touch ASAP

正在测试类似的东西:

$twitter_bot = new twitter_bot_functions($twitter_settings['api_key'], $twitter_settings['api_secret'], $twitter_settings['access_token'], $twitter_settings['access_token_secret']);
$get_latest_mention = $twitter_bot->twitter_get_tweets();
echo $get_latest_mention['text'];

有人知道我做错了什么吗?

【问题讨论】:

    标签: php twitter


    【解决方案1】:

    它首先是一个数组,然后是一个 stdClass 对象。所以你应该像这样使用它

    echo $get_latest_mention[0]->text;

    【讨论】:

    • 感谢您解决了我的问题。
    • 很高兴。还有更多帮助吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    相关资源
    最近更新 更多