api kicking my ass :( I tried 3 different attempts for authorization but no luck
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:capstone_hungry_hippos/screens/twitter_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:twitter_api/twitter_api.dart';
|
||||
import'package:crypto/crypto.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
@@ -15,7 +16,7 @@ final twitterBase = 'https://api.twitter.com/1.1/search';
|
||||
|
||||
final _twitterOauth = new twitterApi(
|
||||
consumerKey: "gsa3eHPVGK90dt6fgUC2ZSbTE",
|
||||
consumerSecret: "rwEjykGOfapPLTVkWgedSCU8Eld130EEHFyu3W0Ye3fDcKj5Vf",
|
||||
consumerSecret: "rwEjykGOfapPLTVkWgedSCU8Eld130EEHFyu3W0Ye3fDcKj5V",
|
||||
token: "910563313108574211-WynoAeUKJrnE6uXPv8vJGx4ITGS1ggG",
|
||||
tokenSecret: "dWFYYbn6J1QTyV86femOdriX7MfMSANSjH3m48ZtEZUNW",
|
||||
);
|
||||
@@ -27,6 +28,7 @@ class TwitterFeedCreation {
|
||||
|
||||
Future<List<Tweet>> getPage() async {
|
||||
|
||||
|
||||
var response = await _twitterOauth.getTwitterRequest(
|
||||
"GET",
|
||||
"/statuses/user_timeline.json",
|
||||
@@ -41,9 +43,29 @@ class TwitterFeedCreation {
|
||||
Iterable tweets = json.decode(response.body);
|
||||
print(tweets);
|
||||
return tweets.map((e) => Tweet.fromJson(e)).toList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
String _getSig(String method, String base, List<String> sortedItems){
|
||||
String param = '';
|
||||
|
||||
for (int i = 0; i < sortedItems.length; i++) {
|
||||
if (i == 0) {
|
||||
param = sortedItems[i];
|
||||
} else {
|
||||
param += '%${sortedItems[i]}';
|
||||
}
|
||||
}
|
||||
String sig = '$method&${Uri.encodeComponent(base)}&${Uri.encodeComponent(param)}';
|
||||
String key = '${Uri.encodeComponent("gsa3eHPVGK90dt6fgUC2ZSbTE")}&${Uri.encodeComponent("rwEjykGOfapPLTVkWgedSCU8Eld130EEHFyu3W0Ye3fDcKj5V")}';
|
||||
|
||||
var digest = Hmac(sha1, utf8.encode(key)).convert(utf8.encode(sig));
|
||||
return base64.encode(digest.bytes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class VerticalTwitterFeed extends StatelessWidget{
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
|
||||
@@ -25,6 +25,7 @@ dependencies:
|
||||
http: ^0.12.0+4
|
||||
shared_preferences: ^0.5.6+3
|
||||
twitter_api: ^0.1.2
|
||||
crypto:
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
||||
Reference in New Issue
Block a user