4 Commits

Author SHA1 Message Date
kwainright
f819278368 api kicking my ass :( I tried 3 different attempts for authorization but no luck 2020-05-03 14:54:57 -04:00
kwainright
68c7b5c5b3 api trouble shooting 2020-05-02 21:51:19 -04:00
kwainright
764dda9ea6 Twitter Page - set up with api - Testing to get response from api 2020-04-22 17:28:09 -04:00
kwainright
c874d2d5c3 Twitter Page - set up with api - not sure that I'm getting a response 2020-04-21 18:59:25 -04:00
6 changed files with 113 additions and 68 deletions

View File

@@ -213,14 +213,9 @@
files = ( files = (
); );
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;

View File

@@ -3,25 +3,10 @@ import 'package:flutter/material.dart';
import '../twitter_assets/tweet.dart'; import '../twitter_assets/tweet.dart';
class TwitterFeed extends StatelessWidget{ class TwitterFeed extends StatelessWidget{
List<Tweet> fuck = [];
final test = new Tweet(1, "We'll get through this together, Niner Nation. #WeAreAllNiners", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
final test2 = new Tweet(2, "Let's test your UNC Charlotte knowledge...do you know why we became the 49ers? Here's the full history on the pioneering spirit that shaped our trajectory http://bit.ly/UNCC-1949", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
final test3 = new Tweet(3, "Niner Nation means uplifting each other. This 4/9 Day, let's show our students why #WeAreAllNiners by supporting the Student Emergency Relief Fund http://bit.ly/UNCC-SER", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
final test4 = new Tweet(4, "Niner Nation: Chancellor Dubois shares that UNC Charlotte will be able to apply our established parking refund procedures with special considerations for the impact of COVID-19.", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
final test5 = new Tweet(5, "4/9 Day is just for us, Niner Nation. From wherever you are, you're family #WeAreAllNiners", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
final test6= new Tweet(6, "Niner Nation, #49erAlumni Gene Johnson 73 is getting us excited for 4/9 Day tomorrow! Put on your Niner gear, call your friends and lets celebrate together virtually \n Were all in this together! ", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
final test7 = new Tweet(7, "From virtual events to one-on-one sessions with counselors, it's easy to stay connected with @UNCCAdmissions", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
fuck.add(test);
fuck.add(test2);
fuck.add(test3);
fuck.add(test4);
fuck.add(test5);
fuck.add(test6);
fuck.add(test7);
return StatefulBuilder( return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold( builder: (context, StateSetter setState) => Scaffold(
@@ -33,7 +18,16 @@ class TwitterFeed extends StatelessWidget{
body: Container( body: Container(
color: Colors.black12, color: Colors.black12,
child: child:
VerticalTwitterFeed(twitterFeed: fuck), FutureBuilder(
future: _buildTwitter(),
builder: (ctx, snapshot){
if(!snapshot.hasData){
return Center(child: CircularProgressIndicator());
}else{
return snapshot.data;
}
},
),
), ),
drawer: Drawer( drawer: Drawer(
child: ListView( child: ListView(
@@ -63,3 +57,7 @@ class TwitterFeed extends StatelessWidget{
} }
} }
Future<VerticalTwitterFeed> _buildTwitter() async {
final feed = TwitterFeedCreation();
return VerticalTwitterFeed(twitterFeed: feed);
}

View File

@@ -3,29 +3,29 @@ import 'package:flutter/material.dart';
class Tweet { class Tweet {
final int id; final int id;
final String text; final String text;
final String userName; //final String userName;
final String userImgUrl; //final String userImgUrl;
final String url; //final String url;
Tweet( Tweet(
this.id, this.id, {
this.text, this.text,
this.userName, // this.userName,
this.userImgUrl, // this.userImgUrl,
this.url, // this.url,
}
); );
/*factory Tweet.fromJson(Map<String, dynamic> json) { factory Tweet.fromJson(Map<String, dynamic> json) {
return Tweet( return Tweet(
json['id_str'], json['id_str'],
text: json['text'], text: json['full_text'],
userName: json['user']['name'], //userName: json['user']['name'],
userImgUrl: json['user']['profile_image_url_https'], //userImgUrl: json['user']['profile_image_url_https'],
url: json['urls']['expanded_url'], //url: json['urls']['expanded_url'],
); );
} }
Commenting out till we figure out the API
*/
@@ -46,7 +46,7 @@ class TwitterCard extends StatelessWidget{
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 0), padding: EdgeInsets.symmetric(vertical: 10, horizontal: 0),
child: ListTile( child: ListTile(
leading: SizedBox( /* leading: SizedBox(
height: 150, height: 150,
width: 75, width: 75,
child: Container( child: Container(
@@ -58,9 +58,9 @@ class TwitterCard extends StatelessWidget{
), ),
), ),
), ),
), ), */
title: Text('${tweet.userName}'), // title: Text('${tweet.userName}'),
subtitle: Text('${tweet.text}'), title: Text('${tweet.text}'),
), ),
), ),
); );

View File

@@ -3,44 +3,85 @@ import 'dart:io';
import 'package:capstone_hungry_hippos/screens/twitter_widget.dart'; import 'package:capstone_hungry_hippos/screens/twitter_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:twitter_api/twitter_api.dart';
import'package:crypto/crypto.dart';
import 'dart:convert'; import 'dart:convert';
import 'tweet.dart'; import 'tweet.dart';
final twitterBase = 'https://api.twitter.com/1.1/search';
final _twitterOauth = new twitterApi(
consumerKey: "gsa3eHPVGK90dt6fgUC2ZSbTE",
consumerSecret: "rwEjykGOfapPLTVkWgedSCU8Eld130EEHFyu3W0Ye3fDcKj5V",
token: "910563313108574211-WynoAeUKJrnE6uXPv8vJGx4ITGS1ggG",
tokenSecret: "dWFYYbn6J1QTyV86femOdriX7MfMSANSjH3m48ZtEZUNW",
);
class TwitterFeedCreation { class TwitterFeedCreation {
static final twitterBase = 'https://api.twitter.com/1.1/search';
static final apiKey = 'AFBfOqx8uXIUBZMxAFoQyO3zA';
static final apiSecret = '48Gp7nczz9SqExorwYuWpA6Nmviuox6Beq83kjH1XtYtunorym';
getToken() async { Future<List<Tweet>> getPage() async {
http.Response response = await http.get('https://api.twitter.com/oauth2/token',);
}
/*Future<List<Tweet>> getPage({int size = 10}) async {
var url = '$twitterBase/tweets.json?q=from%3ACharlotteFTBL&result_type=mixed&count=$size'; var response = await _twitterOauth.getTwitterRequest(
http.Response response = await http.get(url, "GET",
headers: <String, String> {'authorization': apiKey,} "/statuses/user_timeline.json",
options: {
"user_id": "19025957",
"screen_name": "TTCnotices",
"count": "20",
"trim_user": "true",
"tweet_mode": "extended",
}
); );
Iterable tweets = json.decode(response.body); Iterable tweets = json.decode(response.body);
print(tweets);
return tweets.map((e) => Tweet.fromJson(e)).toList(); 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{ class VerticalTwitterFeed extends StatelessWidget{
final List<Tweet> twitterFeed; final TwitterFeedCreation twitterFeed;
const VerticalTwitterFeed({ const VerticalTwitterFeed({
Key key, Key key,
@required this.twitterFeed, @required this.twitterFeed,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
/*
return Container( return Container(
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
@@ -51,9 +92,9 @@ class VerticalTwitterFeed extends StatelessWidget{
); );
}, },
), ),
); ); */
/* return Container( return Container(
child: FutureBuilder( child: FutureBuilder(
future: twitterFeed.getPage(), future: twitterFeed.getPage(),
builder: (ctx, snapshot){ builder: (ctx, snapshot){
@@ -73,6 +114,8 @@ class VerticalTwitterFeed extends StatelessWidget{
} }
}, },
), ),
); */ );
} }
} }

View File

@@ -7,21 +7,21 @@ packages:
name: archive name: archive
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.13" version: "2.0.11"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.0" version: "1.5.2"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.1" version: "2.4.0"
bloc: bloc:
dependency: transitive dependency: transitive
description: description:
@@ -35,21 +35,21 @@ packages:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "1.0.5"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.3" version: "1.1.2"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.12" version: "1.14.11"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@@ -58,12 +58,12 @@ packages:
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
crypto: crypto:
dependency: transitive dependency: "direct main"
description: description:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.4" version: "2.1.3"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -113,7 +113,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.12" version: "2.1.4"
intl: intl:
dependency: transitive dependency: transitive
description: description:
@@ -176,7 +176,7 @@ packages:
name: quiver name: quiver
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.3" version: "2.0.5"
rxdart: rxdart:
dependency: transitive dependency: transitive
description: description:
@@ -230,7 +230,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.5.5"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@@ -272,7 +272,14 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.15" version: "0.2.11"
twitter_api:
dependency: "direct main"
description:
name: twitter_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -293,7 +300,7 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.6.1" version: "3.5.0"
sdks: sdks:
dart: ">=2.6.0 <3.0.0" dart: ">=2.6.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4 <2.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0"

View File

@@ -24,6 +24,8 @@ dependencies:
http: ^0.12.0+4 http: ^0.12.0+4
shared_preferences: ^0.5.6+3 shared_preferences: ^0.5.6+3
twitter_api: ^0.1.2
crypto:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.