Twitter lets you post tweets and get tweets, timeline, friends, and followers from your Twitter account.
You can display this information in a label on your app. For example, you can add an input text box, ask the user to enter in some Tweet text, and then add a button that “posts” the tweet. You can use similar methods to get a tweet or search for a tweet, and then display the text in a label or gallery control in your app.
This topic shows you how to create the Twitter connection, use the Twitter connection in an app, and lists the available functions.
Prerequisites
- Access to Power Apps
- Add the connection
- Create an app from a template, from data, or from scratch
Connect to Twitter
- Start by creating a blank canvas app.
- In the left-hand pane, select Data > Add data.
- Select New connection, and then select Twitter:
- Select from the default shared application, or choose to bring your own application (along with Consumer Key/Consumer Secret).
- Select Connect.
- Choose , enter your Twitter sign in credentials, and then select Authorize app.
- Select Add Data Source. Your connection appears under Data sources:
The Twitter connection has been created, and added to your app. Now, it’s ready to be used.
Use the Twitter connection in your app
Show a timeline
- On the Insert menu, select Gallery, and add any of the With text galleries.
- Let’s show some timelines:
- To show the current user’s timeline, set the Items property of the gallery to the following formulas:
Twitter.HomeTimeline().TweetText
Twitter.HomeTimeline({maxResults:3}).TweetText
- To show another user’s timeline, set the Items property of the gallery to the following formula:
Twitter.UserTimeline( *TwitterHandle* ).TweetText
Enter a Twitter handle in double quotation marks or an equivalent value. For example, enter
"satyanadella"
or"powerapps"
directly in the formula expression. - Add a text input control named Tweep, and set its Default property to
Tweep.Text
. In the Tweep text box, type in a Twitter handle such assatyanadella
(without quotation marks and without the @ symbol).In the gallery control, set the Items property to the following formula:
Twitter.UserTimeline(Tweep.Text, {maxResults:5}).TweetText
The gallery control automatically shows the tweets of the Twitter handler you type in.
Tip
Some of these formulas use the maxResults argument to show the x number of most recent tweets in a timeline.
- To show the current user’s timeline, set the Items property of the gallery to the following formulas:
- Set the gallery’s Items property to
Twitter.HomeTimeline()
.With the gallery selected, the right-hand pane shows options for that gallery.
- Select TweetText in the first list, select TweetedBy in the second list, and select CreatedAt in the third list.
The gallery now shows the values of the properties you chose.
Show followers
- Using a With text gallery, let’s show some followers:
- To show the current user’s followers, set the Items property of the gallery to the following formula:
Twitter.MyFollowers()
Twitter.MyFollowers({maxResults:3})
- To show the another user’s followers, set the Items property of the gallery to the following formula:
Twitter.Followers( *TwitterHandle* )
Enter a Twitter handle in double quotation marks or an equivalent value. For example, enter
"satyanadella"
or"powerapps"
directly in the formula expression. - Add a text input control named Tweep, and set its Default property to
Tweep.Text
. In the Tweep text box, type in a Twitter handle such assatyanadella
(without quotation marks and without the @ symbol).In the gallery control, set the Items property to the following formula:
Twitter.Followers(Tweep.Text, {maxResults:5})
The gallery control automatically shows who is following the Twitter handle you type in.
Tip
Some of these formulas use the maxResults argument to show the x number of most recent tweets in a timeline.
- To show the current user’s followers, set the Items property of the gallery to the following formula:
- Set the gallery’s Items property to
Twitter.MyFollowers()
.With the gallery selected, the right-hand pane shows options for that gallery.
- Select UserName in the second list, and select FullName in the third list.
The gallery now shows the values of the properties you chose.
Show followed users
- Using a With text gallery, let’s show some followed users:
- To show which users the current user is following, set the Items property of the gallery to the following formula:
Twitter.MyFollowing()
Twitter.MyFollowing({maxResults:3})
- To show which users another user is following, set the Items property of the gallery to the following formula:
Twitter.Following( *TwitterHandle* )
Enter a Twitter handle in double quotation marks or an equivalent value. For example, enter
"satyanadella"
or"powerapps"
directly in the formula expression. - Add a text input control named Tweep, and set its Default property to
Tweep.Text
. In the Tweep text box, type in a Twitter handle such assatyanadella
(without quotation marks and without the @ symbol).In the gallery control, set the Items property to the following formula:
Twitter.Following(Tweep.Text, {maxResults:5})
The gallery control automatically shows the other handles you are following.
With the gallery selected, the right-hand pane shows options for that gallery.
- To show which users the current user is following, set the Items property of the gallery to the following formula:
- Select Description in the Body1 list, UserName in the Heading1 list, and FullName in the Subtitle1 list.
The gallery now shows the values of the properties you chose.
Show information about a user
Add a label, and then set its Text property to one of these formulas:
twitter.User( *TwitterHandle* ).Description
twitter.User( *TwitterHandle* ).FullName
twitter.User( *TwitterHandle* ).Location
twitter.User( *TwitterHandle* ).UserName
twitter.User( *TwitterHandle* ).FollowersCount
twitter.User( *TwitterHandle* ).FriendsCount
twitter.User( *TwitterHandle* ).Id
twitter.User( *TwitterHandle* ).StatusesCount
Enter a Twitter handle in double quotation marks or an equivalent value. For example, enter "satyanadella"
or "powerapps"
directly in the formula expression.
Or, you can use an input text control to type in a Twitter handle, just as we have throughout this topic.
Search tweets
- Using a With text gallery, set its Items property to the following formula:
Twitter.SearchTweet( *SearchTerm* ).TweetText
Enter a SearchTerm in double quotation marks or by referring to an equivalent value. For example, enter
"PowerApps"
or"microsoft"
directly in the formula.Or, you can use an Input text control to specify a search term, just as we have throughout this topic.
Tip
Show the first five results by using maxResults:
Twitter.SearchTweet(SearchTerm.Text, {maxResults:5}).TweetText
- Set the gallery’s Items property to
Twitter.SearchTweet(SearchTerm.Text, {maxResults:5})
.With the gallery selected, the right-hand pane shows options for that gallery.
- Select TweetText in the first list, TweetedBy in the second list, and CreatedAt in the third list.
The gallery now shows the values of the properties you chose.
Send a tweet
- Add a text input control, and then rename it MyTweet.
- Add a button, and then set its OnSelect property to the following formula:
Twitter.Tweet("",{tweetText: MyTweet.Text})
Example:Twitter.Tweet("",{tweetText:"Sample tweet!"})
- Press F5, or select the Preview button (
). Type some text into MyTweet, and then select the button to tweet the text that you entered.
- Press Esc to return to the default workspace.