Comments (14)
Update:
Changed up some of the code and added a for loop to iterate through "data" to add each tweet onto a list of tweets, since I think the issue before was that the JSON had "data" and "meta" and all the tweet info is in the "data" section. Updated code is below, however I am now facing a new issue where I get a red error screen with the message "NoSuchMethodError: 'toDouble' Dynamic call of null. Receiver: "1461023836221153286" Arguments:[] See also: https:flutter.dev/docs/testing/errors". Is this a bug or could I be doing something wrong in my code?
Updated code:
Future<List> getTweets() async {
String twitterID = '783214';
Map<String, String> params = {
'exclude': 'retweets,replies',
'tweet.fields':
'attachments,author_id,conversation_id,created_at,entities,referenced_tweets'
};
var response = await http.get(
Uri.https('api.twitter.com', '2/users/$twitterID/tweets', params),
headers: {
"Authorization":
"Bearer myBearerToken"
});
print("this is response.body: \n" + response.body);
Map<String, dynamic> jsonData = new Map();
jsonData = convert.jsonDecode(response.body);
print("decoded version: " + jsonData.toString());
List<dynamic> tweets = [];
for (var t in jsonData["data"]) {
print("this is t: ");
print(t);
tweets.add(t);
}
return tweets;
}
final tweets = handler.getTweets();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Tweets")),
body: Container(
child: Card(
child: FutureBuilder(
future: tweets,
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.data == null) {
return Container(
child: const Center(
child: Center(child: CircularProgressIndicator()),
),
);
} else {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return Container(
child: Column(
children: [
EmbeddedTweetView.fromTweet(
Tweet.fromRawJson(
convert.jsonEncode(snapshot.data[index]),
),
)
],
));
});
}
},
),
),
),
from tweet_ui.
@adrianab
Try to use the v1 Twitter API https://developer.twitter.com/en/docs/twitter-api/v1
This lib supports for now only v1 version and you are using the v2 version :(
from tweet_ui.
Thank you! I've attempted to use a similar request but in the V1 version of the Twitter API using this code:
Future grabJson() async {
var response = await http.get(
Uri.https('api.twitter.com',
'1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2'),
headers: {
"Authorization":
"Bearer myBearerToken"
});
print("this is the response: " + response.body);
}
and I'm getting this error HTML response :
<!DOCTYPE html>
<html lang="en" class="dog">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Twitter / ?</title>
<meta name="version" content="1">
<link href="https://abs.twimg.com/favicons/favicon.ico" rel="shortcut icon"
type="image/x-icon">
<link rel="stylesheet"
href="https://abs.twimg.com/errors/fullscreen_errors-39d97faf8c7cf33e502c3c015176efd
9.css">
</head>
<body dir="auto">
<div class="top">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1519 200">
<defs/>
<path d="M708 103l9-5 13 1 2-2 5 1h8l1-1 42-5h7l7 3v1l12-2a9368 9368 0
0129-6l2-5 12 1 6-2 3 1 2 1v-2l13-2v1l4 2 7-1h1l17-3 1 2 4-1 18-7 3-1 4-1h9l13-1
1-4 3-2 13 1v2l22-2 10-3h6l10 5 16-5 15-3 2-1 8-4 6-2 12-1 7-2 8 5 7 1
22-9h7l5-1v-1l25-3 1 2 5 2v1h11l2 1 8-4h3l-1 1h11l10-6 6 3 9-1 4-1 1 1 1-2 6-1
1-1 10-2h2l7-5v1h4l3-1c11 0 23 2 34-3 2-2 7 0 10 0l12 1 4 1 9 2 12-1 11-3 11
1h4l10-6 17 1 2 1c9 2 19-3 22-11l1-1 9 1 15-5c3-1 9 4 9-5 5 0 5 3 5 7l2 3 4-1
4-2 9-4 3-3h3l8-4 6-3 26 2 7-4h18l7 1c10 3 13-6 17-12l8 4 3-1 14-3 15-2a38 38 0
01-5-1l-8-4 7-8 8-4-10-136-922 71 16 205z"/>
<path d="M-36 193l9-5 13 1 2-2 5 1h8l1-1 42-5h7l7 3v1l12-2a9328 9328 0
0129-6l2-5 12 1 6-2 3 1 2 1v-2l13-2v1l4 2 7-1h1l17-3 1 2 4-1 18-7 3-1 4-1h9l13-1
1-4 3-2 13 1v2l22-2 10-3h6l10 5 16-5 15-3 2-1 8-4 6-2 12-1 7-2 8 5 7 1
22-9h7l5-1v-1l25-3 1 2 5 2v1h11l2 1 8-4h3l-1 1h9a6 6 0 002 0l10-6 6 3 9-1 4-1a6
6 0 001 1l1-2 6-1 1-1 10-2h2l7-5v1h4l3-1c11 0 23 2 34-3 2-2 7 0 10 0l12 1 4 1 9
2 12-1 11-3 11 1h4l10-6 17 1 2 1c9 2 19-3 22-11l1-1 9 1 15-5c3-1 9 4 9-5 5 0 5 3
5 7l2 3 4-1 4-2 9-4 3-3h3l8-4 6-3 26 2 7-4h18l7 1c10 3 13-6 17-12l8 4 3-1 14-3
15-2a37 37 0 01-5-1l-8-4 7-8 8-4-10-136-922 71 16 205z"/>
</svg>
</div>
<div class="container">
<div class="content">
<a href="https://twitter.com" title="Twitter logo"><svg class="bird" viewBox="0
0 24 24"><g><path d="M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49
2.048-2.578-.9.534-1.897.922-2.958 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572
0-4.658 2.086-4.658 4.66 0 .364.042.718.12
1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342 0 1.616.823
3.043 2.072 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 4.14 3.737
4.568-.392.106-.803.162-1.227.162-.3 0-.593-.028-.877-.082.593 1.85 2.313 3.198
4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376 0-.747-.022-1.112-.065 2.062
1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254
0-.2-.005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z"></path></g></svg></a>
<h1 id="header">Nothing to see here</h1>
<p id="description">Looks like this page doesn’t exist. Here’s a picture of a
poodle sitting in a chair for your trouble.</p>
<a id="button_search" href="/" class="button">Looking for this?</a>
</div>
<img id="image" src="https://abs.twimg.com/errors/ErrorState_NotFound.png" alt="A
primped poodle with a bow in its hair sitting in a chair like a human.">
<div class="footer">
<ul>
<li><a href="https://twitter.com/" id="footer_home">Home</a></li>
<li><a href="https://status.twitterstat.us/"
id="footer_status">Status</a></li>
<li><a href="https://twitter.com/tos" id="footer_tos">Terms of
Service</a></li>
<li><a href="https://twitter.com/privacy" id="footer_privacy">Privacy
Policy</a></li>
<li><a href="https://support.twitter.com/articles/20170514"
id="footer_cookie">Cookie Policy</a></li>
<li><a href="https://legal.twitter.com/imprint"
id="footer_imprint">Imprint</a></li>
<li><a
href="https://business.twitter.com/en/help/troubleshooting/how-twitter-ads-wor
k.html" id="footer_ads">Ads info</a></li>
<li dir="ltr">© Twitter <span
id="copyright-year">    </span></li>
</ul>
</div>
</div>
</body>
<script
src="https://abs.twimg.com/errors/404-8651f633fd193e0b546010676a4fac06.js"></script>
</html>
I don't know if this is the best place to ask since it is not fully about the tweet_ui library, but I was hoping you could maybe guide me in the right direction to see what I'm doing wrong. When I ran this curl command
curl "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi" -H "Authorization: Bearer myBearerToken"
in the terminal I was able to get a JSON response, so I'm not completely sure why it just won't work on Flutter/Dart.
from tweet_ui.
We have just published a new, awesome prerelease version - https://pub.dev/packages/tweet_ui/versions/4.0.0-dev.0. You can check it out and give us your feedback.
from tweet_ui.
Hi @wszeborowskimateusz thanks for great package
btw i tried to use version 4.0.0-dev.0
and fetch user timeline tweets.
But somehow in the widget only displaying one
Did i missing something
Thanks
from tweet_ui.
What exactly you want to achieve @cahyowhy ?
With this library you can display one tweet. Maybe you could try having a list view with EmbededTweetView widgets for each user tweet?
from tweet_ui.
If you pass a list of tweets in the controller - the library will just pick the first one. See the snippet from the library below
from tweet_ui.
I see, noted then
Thanks for the clarification @wszeborowskimateusz
from tweet_ui.
thou seems v2 still doesn't support for retweeted tweets yah
from tweet_ui.
What do you mean exactly @cahyowhy? Could you show some example input with current output and description of the expected output?
from tweet_ui.
Hi @wszeborowskimateusz sorry for late replied
This is the expected output
This is the json tweet i used to render the embeded tweet above.
Althou i already tried to use this repo example retweet.json but it still same
I use this version btw
tweet_ui: ^4.0.0-dev.0
from tweet_ui.
Yeah, I see the problem, will try to tackle it in the next release
from tweet_ui.
Hello - just uploaded version [4.0.0-dev.1] - please check if you still have a problem there.
from tweet_ui.
from tweet_ui.
Related Issues (20)
- type 'Null' is not a subtype of type 'double' HOT 15
- Autoplay videos HOT 2
- The data field is an array, but only one TweetView is generated HOT 1
- Should be fixed deprecated method
- Cached images
- Add support for videos in V2 api
- Update photo_view dependency to 0.14.0 HOT 3
- Duplicate classes when compiling HOT 9
- Incompatible with Flutter v2.5.0 HOT 3
- How to create the json file
- Running the example HOT 3
- How to generate the json file HOT 1
- Support Twitter v2 API
- Enable more platforms HOT 2
- Update dependencies HOT 1
- Support for twitter payload V2. HOT 10
- Can't display a single tweet HOT 8
- Tweet with video doesn't show the video HOT 9
- Add the option to show the 'reply_count' on a tweet widget. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tweet_ui.