主要内容

搜索

搜索推文

描述

例子

d=搜索(ctweetquery在推特上搜索这个词tweetquery

例子

d=搜索(ctweetquery参数使用web服务查询参数搜索tweet。推特®REST API定义了web服务查询参数。

例子

d=搜索(ctweetqueryQueryName1, QueryValue1,…,QueryNameN QueryValueN将web服务查询参数指定为一对或多对名称-值参数。

例子

全部折叠

使用Twitter连接对象搜索Twitter。

使用您的凭证创建一个Twitter连接。(本例中的值不代表真实的Twitter凭证。)

consumerkey =“abcdefghijklmnop123456789”;consumersecret =“qrstuvwxyz123456789”;accesstoken =“123456789 abcdefghijklmnop”;accesstokensecret =“123456789 qrstuvwxyz”;C = twitter(consumerkey,consumersecret,accesstoken,accesstokensecret);

检查Twitter连接。如果StatusCode财产具有价值好吧,连接成功。

c.StatusCode
好的

使用Twitter连接对象和搜索词搜索TwitterMathWorks

tweetquery =“MathWorks”;D = search(c,tweetquery)
d = ResponseMessage with properties: StatusLine: 'HTTP/1.1 200 OK' StatusCode: OK Header: [1×25 matlab.net.http.HeaderField] Body: [1×1 matlab.net.http.MessageBody] Completed: 0

d是一个matlab.net.http.ResponseMessage对象。的StatusCode属性显示好吧,表示HTTP请求成功。

访问MathWorks®tweet。显示第12条Tweet。

d.Body.Data.statuses{12}。text
ans = 'MATLAB控制系统示例https://t.co/g2P86srv33'

属性可以搜索其他推文搜索函数。要检索其他Twitter数据,请使用getdata函数。

使用Twitter连接对象搜索20条tweet。指定要检索的tweet数量作为结构。

使用您的凭证创建一个Twitter连接。(本例中的值不代表真实的Twitter凭证。)

consumerkey =“abcdefghijklmnop123456789”;consumersecret =“qrstuvwxyz123456789”;accesstoken =“123456789 abcdefghijklmnop”;accesstokensecret =“123456789 qrstuvwxyz”;C = twitter(consumerkey,consumersecret,accesstoken,accesstokensecret);

检查Twitter连接。如果StatusCode财产具有价值好吧,连接成功。

c.StatusCode
好的

指定搜索词MathWorks在变量中tweetquery.在结构中指定20个Tweets作为字段参数.使用Twitter连接对象,搜索词搜索20条tweettweetquery、结构参数

tweetquery =“MathWorks”;参数。计数= 20;D = search(c,tweetquery,parameters)
d = ResponseMessage with properties: StatusLine: 'HTTP/1.1 200 OK' StatusCode: OK Header: [1×25 matlab.net.http.HeaderField] Body: [1×1 matlab.net.http.MessageBody] Completed: 0

d是一个matlab.net.http.ResponseMessage对象。的StatusCode属性显示好吧,表示HTTP请求成功。

访问MathWorks推文。展示结构数据

d.Body.Data
Ans = struct with fields: status: {20×1 cell} search_metadata: [1×1 struct]

结构数据包含字段状态.这个字段是一个单元格数组结构。单元格数组中的每个结构都包含关于一个Tweet的信息®

访问所有20条推文。

d.Body.Data.statuses {:}
ans =结构体字段:created_at:“星期五2017年4月28日17:51:55 + 0000的id: 1.2345 e + 17 id_str:“123456789101112131”文本:“这个集合以# 400 MATLAB的例子可以帮助你控制系统,卡尔曼滤波器,https://t.co/FWndxKLA6l..。”截断:0实体:[1×1 struct]元数据:[1×1 struct]来源:“Twitter为iPhone”in_reply_to_status_id: [] in_reply_to_status_id_str: [] in_reply_to_user_id: [] in_reply_to_user_id_str: [] in_reply_to_screen_name:[]用户:[1×1 struct]地理:[] coordinates: [] place: [] contributor: [] retweeted_status: [1×1 struct] is_quote_status: 0 retweet_count: 34 favorite_count: 0 favorited: 0 retweeted: 0 posbly_sensitive: 0 lang: 'en'…

这个领域文本在每个结构中包含一条Tweet的文本。

(这些值不代表真实的Twitter数据。)

属性可以搜索其他推文搜索函数。要检索其他Twitter数据,请使用getdata函数。

使用Twitter连接对象搜索20条tweet。指定要检索的tweet数量作为名称-值参数。

使用您的凭证创建一个Twitter连接。(本例中的值不代表真实的Twitter凭证。)

consumerkey =“abcdefghijklmnop123456789”;consumersecret =“qrstuvwxyz123456789”;accesstoken =“123456789 abcdefghijklmnop”;accesstokensecret =“123456789 qrstuvwxyz”;C = twitter(consumerkey,consumersecret,accesstoken,accesstokensecret);

检查Twitter连接。如果StatusCode财产具有价值好吧,连接成功。

c.StatusCode
好的

使用Twitter连接对象,搜索词搜索20条tweetMathWorks,和名值参数

tweetquery =“MathWorks”;D = search(c,tweetquery,“数”, 20)
d = ResponseMessage with properties: StatusLine: 'HTTP/1.1 200 OK' StatusCode: OK Header: [1×25 matlab.net.http.HeaderField] Body: [1×1 matlab.net.http.MessageBody] Completed: 0

d是一个matlab.net.http.ResponseMessage对象。的StatusCode属性显示好吧,表示HTTP请求成功。

访问MathWorks推文。展示结构数据

d.Body.Data
Ans = struct with fields: status: {20×1 cell} search_metadata: [1×1 struct]

结构数据包含字段状态.这个字段是一个单元格数组结构。单元格数组中的每个结构都包含关于一个Tweet的信息。

访问所有20条推文。

d.Body.Data.statuses {:}
ans =结构体字段:created_at:“星期五2017年4月28日17:51:55 + 0000的id: 1.2345 e + 17 id_str:“123456789101112131”文本:“这个集合以# 400 MATLAB的例子可以帮助你控制系统,卡尔曼滤波器,https://t.co/FWndxKLA6l..。”截断:0实体:[1×1 struct]元数据:[1×1 struct]来源:“Twitter为iPhone”in_reply_to_status_id: [] in_reply_to_status_id_str: [] in_reply_to_user_id: [] in_reply_to_user_id_str: [] in_reply_to_screen_name:[]用户:[1×1 struct]地理:[] coordinates: [] place: [] contributor: [] retweeted_status: [1×1 struct] is_quote_status: 0 retweet_count: 34 favorite_count: 0 favorited: 0 retweeted: 0 posbly_sensitive: 0 lang: 'en'…

这个领域文本在每个结构中包含一条Tweet的文本。

(这些值不代表真实的Twitter数据。)

属性可以搜索其他推文搜索函数。要检索其他Twitter数据,请使用getdata函数。

输入参数

全部折叠

Twitter连接,指定为推特对象。

推文搜索词,指定为字符向量或字符串标量。

例子:“MathWorks”

数据类型:字符|字符串

Web服务查询参数,指定为结构。每个参数都被指定为结构中的一个字段。将该字段设置为结构中的特定值。例如,指定要检索的tweet的数量:

参数。计数= 20;

Twitter REST API定义了web服务查询参数,它接受这些参数作为HTTP请求的一部分。

数据类型:结构体

Web服务查询参数,指定为一对或多对名称-值参数。一个QueryName参数是指定查询参数名称的字符向量或字符串标量。一个QueryValue参数是一个字符向量或字符串标量,指定查询参数的值。

Twitter REST API定义了web服务查询参数,它接受这些参数作为HTTP请求的一部分。

例子:“计数”,20检索20条tweet。

数据类型:字符|字符串

输出参数

全部折叠

Twitter数据,返回为matlab.net.http.ResponseMessage对象。

要检索Twitter数据,请访问d,例如:

data = d.Body.Data
Data = struct with fields: status: {50×1 cell} search_metadata: [1×1 struct]

继续访问嵌套结构数据来检索推特数据。有关访问嵌套结构,请参见在嵌套结构中访问数据

限制

  • Twitter REST API得到搜索/微博endpoint指定你一次最多可以检索100条tweet。

  • Twitter REST API得到搜索/微博endpoint指定您可以检索最多7天的历史推文。

版本历史

在R2017b中引入