Delivering Efficiency so you can complete your mission with precision. 

Menu

Connect to Twitter from Power Apps

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

Connect to Twitter

  1. Start by creating a blank canvas app.
  2. In the left-hand pane, select Data > Add data.
  3. Select New connection, and then select Twitter:

    Add connection.

  4. Select from the default shared application, or choose to bring your own application (along with Consumer Key/Consumer Secret).
  5. Select Connect.
  6. Choose , enter your Twitter sign in credentials, and then select Authorize app.
  7. Select Add Data Source. Your connection appears under Data sources:
    Close the Options pane.

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

  1. On the Insert menu, select Gallery, and add any of the With text galleries.
  2. 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 as satyanadella (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.

  3. Set the gallery’s Items property to Twitter.HomeTimeline().

    With the gallery selected, the right-hand pane shows options for that gallery.

  4. 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

  1. 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 as satyanadella (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.

  2. Set the gallery’s Items property to Twitter.MyFollowers().

    With the gallery selected, the right-hand pane shows options for that gallery.

  3. 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

  1. 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 as satyanadella (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.

  2. 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

  1. 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

  2. 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.

  3. 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

  1. Add a text input control, and then rename it MyTweet.
  2. Add a button, and then set its OnSelect property to the following formula:
    Twitter.Tweet("",{tweetText: MyTweet.Text})
    Example: Twitter.Tweet("",{tweetText:"Sample tweet!"})
  3. Press F5, or select the Preview button (Preview button.). Type some text into MyTweet, and then select the button to tweet the text that you entered.
  4. Press Esc to return to the default workspace.

Recents Posts