搜索

此内容没有您所选择的语言版本。

Chapter 23. Connecting to Twitter

download PDF

To connect to Twitter in an integration, the main steps are:

You need a Twitter developer account to authorize access from your Fuse Online environment to Twitter. If you do not already have a Twitter developer account, go to https://apps.twitter.com, sign in to Twitter, and click Apply for a developer account. Obtaining the developer account is quick when you provide a professional email address, such as me@redhat.com rather than a personal address such as you@gmail.com.

23.1. Registering Fuse Online as a Twitter client application

In an integration, to connect to Twitter, the first thing you must do is register your Fuse Online environment as a client application that can access Twitter. This lets you create any number of integrations that connect to Twitter. In other words, you need to register a particular Fuse Online environment with Twitter only once.

In each Fuse Online environment, there can be only one registration of Fuse Online as a Twitter client application. However, while each Twitter connection uses the same registration, it can use different user credentials.

Prerequisite

You are logged in to Fuse Online. The URL for accessing Fuse Online is in the email message that welcomed you to the Red Hat Fuse Online Evaluation program.

Procedure

  1. In Fuse Online:

    1. In the left panel, click Settings.
    2. On the Settings page, near the top, to the right of the callback URL, click Copy Callback URL to copy the callback URL for your installation of Fuse Online to the clipboard. You will need this URL later in this procedure.
    3. Click the Twitter entry to display the Consumer API Key and Consumer API Secret Key fields.
  2. In another browser tab, go to your Twitter developer account, sign in if you need to, and do the following:

    1. In the upper right, next to the name of your developer project, click the down caret and click Apps.
    2. In the upper right, click Create an app.
    3. In the App name field, enter a name such as My Fuse Online Client.
    4. In the Application description field, enter a tip such as For leveraging tweets.
    5. In the Website URL field, paste the URL that you copied at the beginning of this procedure and remove api/v1/credentials/callback from the end of the URL.
    6. Select Enable Sign in with Twitter.
    7. In the Callback URLs field, paste the URL again. It should be something like this: https://app-proj912876.7b63.fuse-ignite.openshiftapps.com/api/v1/credentials/callback.

      You can skip the next few fields.

    8. Tell us how this app will be used requires a 100-character description. For convenience, you can copy and paste: This is a demo application so that I can evaluate how to integrate Twitter with my enterprise applications.
    9. Click Create.
    10. Click Create again to confirm that you reviewed the developer terms.
    11. At the top of the page for the app you just created, click the Keys and tokens tab.
    12. Copy the consumer API key.
  3. Return to your Fuse Online Settings page and paste the Twitter consumer API key into the Fuse Online Twitter Consumer API Key field.
  4. Return to the Twitter Keys and tokens tab and copy the consumer API secret key.
  5. Return to your Fuse Online Settings page and paste the Twitter consumer API secret key into the Fuse Online Twitter Consumer API Secret Key field.
  6. Click Save.
  7. Click the Twitter entry to collapse it.

23.2. Creating a Twitter connection

To create an integration that obtains data from Twitter, you must first create a Twitter connection. After you create a Twitter connection, you can use it in any number of integrations.

Prerequisites

  • You are logged in to Fuse Online. The URL for accessing Fuse Online is in the email message that welcomed you to the Red Hat Fuse Online Evaluation program.
  • Fuse Online is open in a web browser.
  • You registered your Fuse Online environment as an application that can access Twitter.
  • You added the Twitter consumer API key and consumer API secret key that you received after registration to the Fuse Online Settings page.

Procedure

  1. In Fuse Online, in the left panel, click Connections to display any available connections.
  2. In the upper right, click Create Connection to display the available connectors. A connector is a template that you use to create one or more connections.
  3. Click the Twitter connector.
  4. Click Connect Twitter to display a Twitter authorization page. You might need to log in to Twitter before you see the authorization page.

    If Connect Twitter does not appear, then your Fuse Online environment is not registered as a Twitter client application. See Registering Fuse Online as a Twitter client application. When you try to create a Twitter connection and your Fuse Online environment is not registered as a Twitter client application, then Fuse Online displays multiple fields that prompt for authorization information. While you can create a Twitter connection by entering values in these fields, it is not recommended.

  5. Click Authorize app to return to Fuse Online.
  6. In the Name field, enter your choice of a name that helps you distinguish this connection from any other connections. For example, enter Twitter Connect 1.
  7. In the Description field, optionally enter any information that is helpful to know about this connection. For example, enter Sample Twitter connection that uses my Twitter login credentials.
  8. Click Save to see that the connection you created is now available. If you entered the example name, you would see that Twitter Connect 1 appears as a connection that you can choose to add to an integration.

23.3. Adding a Twitter connection to trigger integration execution

In a simple integration, the start connection can be a Twitter connection that triggers execution of the integration when it finds certain tweets or direct messages.

Prerequisites

  • You created a Twitter connection.
  • You are creating or editing a simple integration and Fuse Online is prompting you to choose the start connection.

Procedure

  1. Click the Twitter connection that starts the integration. When the integration uses the selected connection to connect to Twitter, Fuse Online uses the credentials defined in that connection.
  2. Select the action that you want the connection to perform. A Twitter connection that you add to an integration performs only the action that you choose:

    • Mention monitors Twitter for tweets that contain the Twitter handle for the Twitter account that the connection is authorized to access. Upon finding such a tweet, the connection returns it to Fuse Online, which triggers execution of the integration.
    • Retrieve periodically polls Twitter for direct messages sent to the Twitter account that the Twitter connection is authorized to access. Upon finding such messages, the connection returns them to Fuse Online, which triggers execution of the integration.
    • Search periodically polls Twitter for tweets that match criteria that you specify. Upon finding such tweets, the connection returns them to Fuse Online, which triggers execution of the integration.
  3. Configure the action that you selected:

    • Mention does not require any configuration.
    • Retrieve

      • Count has a default of 100 and you should not need to change this value, which affects internal behavior. However, do not set this value to less than 50 because doing so might decrease performance.

        The Retrieve action always returns all previously unreturned direct messages received in the last 30 days. If you do not select Ignore direct messages previously found, then the Retrieve action returns all messages that have been received in the last 30 days.

      • Delay is the period of time between polls. Twitter enforces rate limits, so you should not poll too often. The default interval is 5 seconds.
      • Ignore direct messages previously found returns only new messages when selected.
    • Search

      • Delay is the period of time between polls. Twitter enforces rate limits, so you should not poll too often. The default interval is 5 seconds.
      • Ignore tweets previously found returns only new tweets when selected.
      • Query is a Twitter-formatted search expression that specifies the tweets that you want the connection to return. The following table provides examples of what you can enter. More details are in this Twitter document for search operators.

        Query

        Results

        My Product

        Obtains tweets that contain both My and Product, but not necessarily My Product.

        "My Product”

        Obtains tweets that contain an instance of My Product.

        My OR Product

        Obtains tweets that contain an instance of My or Product or an instance of each one.

        My -Product

        Obtains tweets that contain an instance of My and do not contain an instance of Product.

        #MyProduct

        Obtains tweets that contain the MyProduct hashtag.

  4. Click Next to add the connection to the integration.

Result

The integration now has a start connection and Fuse Online is prompting you to choose the finish connection.

23.4. Adding a Twitter connection that sends a direct message

In the middle of a flow, or to finish a simple integration, you can add a Twitter connection that sends a direct message to a Twitter user. A direct message is a private message that goes to only the specified user.

Prerequisites

  • You created a Twitter connection.
  • You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, for a simple integration, Fuse Online is prompting you to choose a finish connection.

Procedure

  1. On the Add to Integration page, click the plus sign where you want to add a Twitter connection.
  2. Click the Twitter connection that you want to add to the integration. When the integration uses the selected connection to connect to Twitter, Fuse Online uses the credentials defined in that connection.
  3. Select the Send action.
  4. In the Default Message field, enter the message that you want the connection to send when a data mapper step does not map the direct message content from a previous step to this Twitter connection. While you must enter a message when you configure this Twitter connection, a message that you map from a previous step has precedence over the message that you specify here.
  5. In the User field, enter the Twitter handle of the user who you want to send a direct message to. For example, both Aslan and @Aslan are correct.
  6. Click Next to add the connection to the integration.

Result

The connection appears in the middle or at the end of an integration visualization.

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.