判断一条推文是否是转推?

编程入门 行业动态 更新时间:2024-10-20 15:47:49
本文介绍了判断一条推文是否是转推?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我使用 Twitter API 来提取特定用户的推文.我让它完全按照我的意愿工作,除了能够判断特定推文是来自用户的原创还是转推.

I'm using the Twitter API in order to pull tweets from specific users. I have it working exactly as I want, except for being able to tell whether or not a specific tweet is original from the user or if it is a retweet.

我正在使用以下调用:https://api.twitter/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=philipprucker&count=1

查看结果时,似乎我应该能够从结果中提取 retweeted 并且它应该返回 true 或 false.但是,这仅返回字符串 retweet.

When looking at the results, it appears that I should be able to pull retweeted from the results and it should return true or false. However, this is only returning the string retweet.

$url = "http://api.twitter/1/statuses/user_timeline.xml?include_entities=true&include_rts=true&screen_name=$screen_name&count=200" ;
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$xml = curl_exec ($ch);
curl_close ($ch);

$twelement = new SimpleXMLElement($xml);
foreach ($twelement->status as $status) {
    $text = dbEscape(trim($status->text));
    $time = strtotime($status->created_at);
    $id = $status->id;
    $num_retweets = $status->retweet_count;
    $retweet = $status->retweeted;
    dbQuery("INSERT INTO `twitter` (`id`,`screen_name`,`time`,`text`,`hidden`, `numRetweets`, `retweet`) VALUES ('$id','$screen_name','$time','$text','n','$num_retweets','retweet')");
    // dbQuery("INSERT INTO `twitter` (`id`,`screen_name`,`time`,`text`,`hidden`) VALUES ('$id','$screen_name','$time','$text','n')");
}

这是执行我描述的代码.我相信所有相关的代码都在那里.任何帮助将不胜感激!

This is the code doing what I describe. I believe all the relevant code is there. Any help would be greatly appreciated!

推荐答案

您特意将字符串 retweet 放入表格中,而不是 $retweet 的值.

You are specifically putting the string retweet into the table, not the value of $retweet.

这篇关于判断一条推文是否是转推?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 15:25:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/942687.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是转推

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!