twitter_api 0.1.1 copy "twitter_api: ^0.1.1" to clipboard
twitter_api: ^0.1.1 copied to clipboard

outdated

An easy way to authenticate and make requests to the Twitter API.

example/example.dart

import 'package:twitter_api/twitter_api.dart';

// Used for the decode
import 'dart:convert';

Future main() async {

  // Setting placeholder api keys
  String consumerApiKey = "ABC";
  String consumerApiSecret = "ABC";
  String accessToken = "ABC";
  String accessTokenSecret = "ABC";

  // Creating the twitterApi Object with the secret and public keys
  // These keys are generated from the twitter developer page
  // Dont share the keys with anyone
  final _twitterOauth = new twitterApi(
    consumerKey: consumerApiKey,
    consumerSecret: consumerApiSecret,
    token: accessToken,
    tokenSecret: accessTokenSecret
  );

  // Make the request to twitter
  Future twitterRequest = _twitterOauth.getTwitterRequest(
    // Http Method
    "GET", 
    // Endpoint you are trying to reach
    "statuses/user_timeline.json", 
    // The options for the request
    options: {
      "user_id": "19025957",
      "screen_name": "TTCnotices",
      "count": "20",
      "trim_user": "true",
      "tweet_mode": "extended", // Used to prevent truncating tweets
    },
  );

  // Wait for the future to finish
  var res = await twitterRequest;

  // Print off the response
  print(res.statusCode); 
  print(res.body);

  // Convert the string response into something more useable
  var tweets = json.decode(res.body);
  print(tweets);
}
24
likes
40
pub points
42%
popularity

Publisher

unverified uploader

An easy way to authenticate and make requests to the Twitter API.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

crypto, http

More

Packages that depend on twitter_api