我是C#和asp.net的新手。 我正在尝试创建一个使用Twitter的流媒体和搜索API的简单网站(在localhost上运行)。
我尝试了一些查询,例如:“https://api.twitter.com/1.1/statuses/mentions_timeline.json?count=2&since_id=14927799”但是它有一些关于“错误验证数据”的错误。
可能是我不知道如何获得身份验证。那么有人可以帮助我吗?感谢很多。
答案 0 :(得分:1)
您展示的不是搜索功能,而是流功能。 以下是工作twitter流搜索的完整示例
select *
from SampleTable
where /* Some conditions.... and*/
(convert(date, StartTime) >= @dateStart) and
(case when (DateCreated between cast(cast(cast(DateCreated as date) as varchar(40)) + ' 19:00:00' as datetime)
and cast(cast(cast(DateCreated as date) as varchar(40)) + ' 23:59:59' as datetime)
or
DateCreated between cast(cast(cast(DateCreated as date) as varchar(40)) + ' 00:00:00' as datetime)
and cast(cast(cast(DateCreated as date) as varchar(40)) + ' 07:00:00' as datetime)
)
and Workshift like '%N'
then dateadd(day,-1,cast(cast(DateCreated as date) as varchar(40)))
else DateCreated
end <= @dateEnd)
答案 1 :(得分:0)
首先,您应该创建一个应用程序。 https://dev.twitter.com/apps。
然后,您可以使用Twitterizer
&#39; WebRequestBuilder
课程来表达您的请求。 (http://svn.twitterizer.net/twitterizer/trunk/Twitterizer2/OAuth/)
var tokens = new Twitterizer.OAuthTokens
{
ConsumerKey = "....",
ConsumerSecret = "....",
AccessToken = "....",
AccessTokenSecret = "......"
};
string url = "https://api.twitter.com/1.1/statuses/mentions_timeline.json?count=2&since_id=14927799";
var builder = new Twitterizer.WebRequestBuilder(new Uri(url), Twitterizer.HTTPVerb.GET, tokens);
var req = builder.PrepareRequest();
var resp = req.GetResponse();
var json = new StreamReader(resp.GetResponseStream()).ReadToEnd();
resp.Close();