Twitter Page - set up with api - not sure that I'm getting a response

This commit is contained in:
kwainright
2020-04-21 18:59:25 -04:00
parent 99cff9ac7a
commit c874d2d5c3
6 changed files with 78 additions and 72 deletions

View File

@@ -213,14 +213,9 @@
files = (
);
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";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;

View File

@@ -3,25 +3,10 @@ import 'package:flutter/material.dart';
import '../twitter_assets/tweet.dart';
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
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(
builder: (context, StateSetter setState) => Scaffold(
@@ -33,7 +18,7 @@ class TwitterFeed extends StatelessWidget{
body: Container(
color: Colors.black12,
child:
VerticalTwitterFeed(twitterFeed: fuck),
VerticalTwitterFeed(),
),
drawer: Drawer(
child: ListView(

View File

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

View File

@@ -3,44 +3,60 @@ import 'dart:io';
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 'dart:convert';
import 'tweet.dart';
final twitterBase = 'https://api.twitter.com/1.1/search';
final apiKey = 'AFBfOqx8uXIUBZMxAFoQyO3zA';
final apiSecret = '48Gp7nczz9SqExorwYuWpA6Nmviuox6Beq83kjH1XtYtunorym';
final token = '910563313108574211-NNlQlPdbHWlNyFglwzrtD1dMpyDrNrF';
final tokenSecret = 'aW4aJBQH2EPvoyc3gtR0qSKepccmuEtAj2sH7dzh2w8sN;';
final _twitterOauth = new twitterApi(
consumerKey: apiKey,
consumerSecret: apiSecret,
token: token,
tokenSecret: tokenSecret,
);
class TwitterFeedCreation {
static final twitterBase = 'https://api.twitter.com/1.1/search';
static final apiKey = 'AFBfOqx8uXIUBZMxAFoQyO3zA';
static final apiSecret = '48Gp7nczz9SqExorwYuWpA6Nmviuox6Beq83kjH1XtYtunorym';
getToken() 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';
http.Response response = await http.get(url,
headers: <String, String> {'authorization': apiKey,}
Future<List<Tweet>> getPage() async {
var twitterRequest = _twitterOauth.getTwitterRequest(
"GET",
"/statuses/user_timeline.json",
options: {
"user_id": "19025957",
"screen_name": "TTCnotices",
"count": "20",
"trim_user": "true",
"tweet_mode": "extended",
}
);
var response = await twitterRequest;
Iterable tweets = json.decode(response.body);
return tweets.map((e) => Tweet.fromJson(e)).toList();
} */
}
}
class VerticalTwitterFeed extends StatelessWidget{
final List<Tweet> twitterFeed;
final twitterFeed = TwitterFeedCreation().getPage();
const VerticalTwitterFeed({
Key key,
@required this.twitterFeed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
/*
return Container(
child: ListView.builder(
scrollDirection: Axis.vertical,
@@ -51,11 +67,11 @@ class VerticalTwitterFeed extends StatelessWidget{
);
},
),
);
); */
/* return Container(
return Container(
child: FutureBuilder(
future: twitterFeed.getPage(),
future: twitterFeed,
builder: (ctx, snapshot){
if(!snapshot.hasData){
return Center(child: CircularProgressIndicator());
@@ -73,6 +89,8 @@ class VerticalTwitterFeed extends StatelessWidget{
}
},
),
); */
);
}
}

View File

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

View File

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