Im using linq-to-twitter and I want to pass in a tag to search from and collect the data (the text, username, user picture. I can return a search entity, but I want to go further to find the text, and in the docs it says the Search entity has a result field which is a list of SearchEntities, but it is not appearing for me. I got the red lines under it for both of the below cases:
Im使用linq-to-twitter,我想传递一个标签来搜索和收集数据(文本、用户名、用户图片)。我可以返回一个搜索实体,但我想进一步查找文本,在文档中,它说搜索实体有一个结果字段,它是一个搜索实体列表,但我没有看到它。下面两种情况的红线都在下面:
Case 1:
案例1:
using (var twitterCtx = new TwitterContext())
{
var searchResults =
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == tag &&
search.IncludeEntities == true
select search)
.SingleOrDefault();
searchResults.Results.ForEach(entry =>
{
....
and Case 2: (I just embedded it for a quick example)
案例2:(我把它嵌入了一个简单的例子)
var latestTweets= (from tweet in twitterCtx.Search
where tweet.Count == 200 &&
tweet.Hashtag.Contains(tag)
select tweet).Take(20);
foreach (var tweet in latestTweets)
{
foreach(var tweet2 in tweet.Result)
.Result just isn't showing up... EDIT: API doc
.结果就是没有出现……编辑:API文档
1 个解决方案
#1
2
There are a few things happening here. First, is that LINQ to Twitter now implements Twitter API v1.1, which means that all queries, including Search, must be authenticated. I have documentation here on how to use OAuth with LINQ to Twitter at Securing Your Applications. The downloadable source code and Sample page has examples too.
这里发生了一些事情。首先,LINQ to Twitter现在实现了Twitter API v1.1,这意味着所有查询(包括搜索)都必须经过身份验证。我这里有关于如何使用OAuth与LINQ到Twitter来保护您的应用程序的文档。可下载的源代码和示例页面也有示例。
The next thing that happens occasionally is that Twitter might not be returning data for your query. Their search engine is optimized for certain types of queries and they don't guarantee a search engine quality response. You can check this by visiting their Search page and enter the same data as the query you're trying to use with LINQ to Twitter. They have a link for Advanced Search too.
接下来偶尔会发生的事情是Twitter可能不会为您的查询返回数据。他们的搜索引擎针对特定类型的查询进行了优化,但不能保证搜索引擎的质量响应。您可以访问他们的搜索页面并输入与您试图在LINQ到Twitter中使用的查询相同的数据来检查这一点。他们也有高级搜索的链接。
If you think something might be wrong with LINQ to Twitter, capture the HTTP traffic with Fiddler and show me the request and response. Note: be sure to sanitize credentials so they don't appear in public.
如果您认为LINQ to Twitter可能有问题,请使用Fiddler捕获HTTP流量并向我显示请求和响应。注意:一定要对凭证进行消毒,以免在公共场合出现。
Another thing is that the second query, using the Contains operator, won't work. LINQ to Twitter only uses equality operators in filters, which become the parameters sent to Twitter. If you want more sophisticated queries, first get the data back from Twitter and then do a LINQ to Objects query. The rationale is that the Twitter API doesn't recognize special operators and introducing this artificiality wouldn't let you know what's truly happening on the wire, which affects the performance of your app.
另一件事是第二个查询(使用Contains操作符)不能工作。LINQ to Twitter只在过滤器中使用平等操作符,这将成为发送给Twitter的参数。如果您想要更复杂的查询,首先从Twitter获取数据,然后执行LINQ到对象查询。其基本原理是,Twitter API不承认特殊的操作符,引入这种人为的操作符不会让您知道网络上真正发生了什么,这会影响应用程序的性能。
@JoeMayo
#1
2
There are a few things happening here. First, is that LINQ to Twitter now implements Twitter API v1.1, which means that all queries, including Search, must be authenticated. I have documentation here on how to use OAuth with LINQ to Twitter at Securing Your Applications. The downloadable source code and Sample page has examples too.
这里发生了一些事情。首先,LINQ to Twitter现在实现了Twitter API v1.1,这意味着所有查询(包括搜索)都必须经过身份验证。我这里有关于如何使用OAuth与LINQ到Twitter来保护您的应用程序的文档。可下载的源代码和示例页面也有示例。
The next thing that happens occasionally is that Twitter might not be returning data for your query. Their search engine is optimized for certain types of queries and they don't guarantee a search engine quality response. You can check this by visiting their Search page and enter the same data as the query you're trying to use with LINQ to Twitter. They have a link for Advanced Search too.
接下来偶尔会发生的事情是Twitter可能不会为您的查询返回数据。他们的搜索引擎针对特定类型的查询进行了优化,但不能保证搜索引擎的质量响应。您可以访问他们的搜索页面并输入与您试图在LINQ到Twitter中使用的查询相同的数据来检查这一点。他们也有高级搜索的链接。
If you think something might be wrong with LINQ to Twitter, capture the HTTP traffic with Fiddler and show me the request and response. Note: be sure to sanitize credentials so they don't appear in public.
如果您认为LINQ to Twitter可能有问题,请使用Fiddler捕获HTTP流量并向我显示请求和响应。注意:一定要对凭证进行消毒,以免在公共场合出现。
Another thing is that the second query, using the Contains operator, won't work. LINQ to Twitter only uses equality operators in filters, which become the parameters sent to Twitter. If you want more sophisticated queries, first get the data back from Twitter and then do a LINQ to Objects query. The rationale is that the Twitter API doesn't recognize special operators and introducing this artificiality wouldn't let you know what's truly happening on the wire, which affects the performance of your app.
另一件事是第二个查询(使用Contains操作符)不能工作。LINQ to Twitter只在过滤器中使用平等操作符,这将成为发送给Twitter的参数。如果您想要更复杂的查询,首先从Twitter获取数据,然后执行LINQ到对象查询。其基本原理是,Twitter API不承认特殊的操作符,引入这种人为的操作符不会让您知道网络上真正发生了什么,这会影响应用程序的性能。
@JoeMayo