首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tweetinvi总是返回null

tweetinvi总是返回null
EN

Stack Overflow用户
提问于 2015-01-07 22:06:46
回答 1查看 1.9K关注 0票数 2

我一直在尝试让tweetinvi工作,无论我做什么,它总是返回null。我已经尝试了3个查询与搜索,速率限制和登录的用户和所有返回null。不知道我做错了什么:这是我第一次尝试使用twitter api

Form1

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using Tweetinvi;
using Tweetinvi.Core.Enum;
using Tweetinvi.Core.Extensions;
using Tweetinvi.Core.Interfaces;
using Tweetinvi.Core.Interfaces.Controllers;
using Tweetinvi.Core.Interfaces.DTO;
using Tweetinvi.Core.Interfaces.DTO.QueryDTO;
using Tweetinvi.Core.Interfaces.Models;
using Tweetinvi.Core.Interfaces.Models.Parameters;
using Tweetinvi.Core.Interfaces.oAuth;
using Tweetinvi.Core.Interfaces.Streaminvi;
using Tweetinvi.Json;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
     //   TwitterCredentials.SetCredentials("xx", "xx", "xx", "xx");
    }

    public void Search_SimpleTweetSearch()
    {
        // IF YOU DO NOT RECEIVE ANY TWEET, CHANGE THE PARAMETERS!
        var tweets = Search.SearchTweets("hi");

        foreach (var tweet in tweets)
        {
          //  Console.WriteLine("{0}", tweet.Text);
            textBox1.Text += "tweet.Text" + System.Environment.NewLine;
        }
    }

    public void test()
    {
        var user = User.GetLoggedUser();
        textBox1.Text += user.ScreenName + System.Environment.NewLine;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        test();
       // Search_SimpleTweetSearch();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        var rateLimits = RateLimit.GetCurrentCredentialsRateLimits();
        textBox1.Text += rateLimits.ToString() + System.Environment.NewLine;
    }


}
}

Program.cs

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Tweetinvi;
using Tweetinvi.Core.Enum;
using Tweetinvi.Core.Extensions;
using Tweetinvi.Core.Interfaces;
using Tweetinvi.Core.Interfaces.Controllers;
using Tweetinvi.Core.Interfaces.DTO;
using Tweetinvi.Core.Interfaces.DTO.QueryDTO;
using Tweetinvi.Core.Interfaces.Models;
using Tweetinvi.Core.Interfaces.Models.Parameters;
using Tweetinvi.Core.Interfaces.oAuth;
using Tweetinvi.Core.Interfaces.Streaminvi;
using Tweetinvi.Json;

namespace WindowsFormsApplication4
{
static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        TwitterCredentials.SetCredentials("xx", "xx", "xx", "xx");
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
}
EN

回答 1

Stack Overflow用户

发布于 2015-05-12 22:55:51

您可以使用ExceptionHandler获取有关哪里出了问题的更多信息。该库的目标不是抛出异常,而是返回null,并将有关错误的信息添加到位于Tweetinvi名称空间中的ExceptionHandler类中。因此,尝试检查返回的对象是否为null,然后查看ExceptionHandler...如下所示:

代码语言:javascript
复制
if (tweets == null)
{
    textBox1.Text += ExceptionHandler.GetLastException().TwitterDescription;
}

最有可能的罪魁祸首是您实际上没有经过身份验证。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27821244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档