Giter Site home page Giter Site logo

picobird's Introduction


PicoBird—Yet another simple Twitter library for .NET

Usage

  • Initialize

    PicoBird.API api = new PicoBird.API("<CONSUMER_KEY>", "<CONSUMER_SECRET>");
    
    // Assign OAuth token and token secret if you already have ones.
    api.Token = "<OAUTH_TOKEN>";
    api.TokenSecret = "<OAUTH_TOKEN_SECRET>";
    
    // Or call RequestToken to fetch them from Twitter API server.
    // Note that RequestToken method requires a callback function
    // which takes one string argument, which is the URL to the
    // authentication page.
    api.OAuthCallback = "oob";
    await api.RequestToken((string url) =>
    {
        System.Diagnostics.Process.Start(url);
        Console.Write("Input PIN> ");
        return Console.ReadLine();
    });
    
    // On succeess, api.Token and api.TokenSecret should be populated
    // with appropriate values at this point.
  • Access Twitter API Resources

    using System.Collections.Specialized;
    using System.Net.Http;
    
    // PicoBird.API.Get() method returns raw HttpResponseMessage objects.
    HttpResponseMessage res = await api.Get(
        "/1.1/statuses/home_timeline.json",
        new NameValueCollection
        {
            { "include_entities", "true" }
        });
  • Using Twitter object wrapper classes (defined in PicoBird.Objects namespace)

    using PicoBird.Objects;
    
    User user = await api.Get<User>("/1.1/account/verify_credentials.json");
    Console.WriteLine($"Name: {user.name}");
    
    Tweet[] home = await api.Get<Tweet[]>("/1.1/statuses/home_timeline.json");
    foreach (Tweet status in home)
        Console.WriteLine($"@{status.user.screen_name}: {status.text}");
  • PicoBird now supports userstream.

    WARNING: PicoBird's streaming support is experimental and it does not provide all the functionality listed in the official specification. And the behaviors are subject to change at any time. Use with caution.

    api.Streaming.UserStream(
      status =>
      {
        // On new tweets
      },
      (id, uid) =>
      {
        // When someone deleted a tweet
        // id: id_str of deleted tweet
        // uid: id_str of the user who deleted the tweet
      }
    );

Todo

  • finding out what to do next

License

MIT License. See LICENSE.md for the full text.

Credits

This project uses Newtonsoft's Json.NET (MIT License)

Copyright

Copyright © 2016, Dalgona. [email protected]

picobird's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.