Sie sind auf Seite 1von 6

Getting Started with the LabVIEW Twitter Toolkit

Step A: Configure your Twitter Account and Acquire Access Tokens


1. First, create a Twitter account at www.twitter.com, or use your existing account 2. Using your twitter account, login to dev.twitter.com 3. Once logged in, select Create an application

Figure 1: Create an Application

4. On the Create an application screen, fill out your application details. The website you use can be any website of your choosing, and it represents the website that identifies your particular application if a user searches for the app on twitter.com. For accessing the application from LabVIEW using the Twitter Toolkit, the callback URL should remain unspecified.

Figure 2: Fill in Application Details

5. Once your application has been created, the next screen you will see will give you some account details. The next important step is to change your applications access level to Read and Write. To do this, navigate to the settings tab, and change the access level as shown in Figure 3.

Figure 3: Change Access Level to Read and Write

6. Once your application has been created, the next screen you see will give you access to your consumer secret and consumer token. These are the secret tokens that identifies your application to Twitter, so keep them safe! Save these tokens as they will be used in subsequent steps. The Request Token URL, the Authorize URL, and the Access Token URL are constant amongst all applications and are automatically handled for you within the Twitter Toolkit.

Figure 4: Acquire Consumer Key and Consumer Secret (blacked out in this image)

Step B: Using the Twitter API in LabVIEW


1. Find your Twitter API Vis in the Functions Palette in LabVIEW as shown in the image below: 2. Now youre ready to use your Twitter Vis in LabVIEW. Find them in your Functions Palette at the location shown below.

Figure 5: Using your Twitter VIs in LabVIEW

3. Configure the Open Twitter.vi The Open Twitter.vi requires the Consumer Secret and the Consumer Token specific to your application. You may notice that it also includes optional inputs for the Access Secret and the Access Token. Just as your Consumer Secret and Consumer Token uniquely identified your application, the Access Secret and Access Token uniquely identify your user account. In both cases, you can think of the Secret and Token combinations as a type of user name and password.

Figure 6: Open Twitter.vi

When you first run the Open Twitter.vi, you may not have your Access Secret and Access Token. If you leave the Access Token and Access Secret inputs unwired, you will be prompted to log into your Twitter account. Once you have completed the login, the Open Twitter.vi will then output a Twitter handle, as well as the Access Token and Access Secret that uniquely identify your user account. To avoid having to login to Twitter each time you run the Open Twitter.vi, you can save the Access Secret and Access Token outputs specific to your user account, and wire them as inputs for the next time the VI is run. If they are provided as inputs to the VI, the Open Twitter.vi will verify the provided Access Secret and Access Token, and if they are correct, a second login will not be required. This concept is explored in the example Post New Tweet.vi, where the tokens are saved between VI accesses using a shift register.

Figure 5: Twitter Authorization Procedure

4. Once you have configured the Open Twitter.vi, you will be able to expand on your program to post tweets, @mention others, and post tweets with media. You will also be able to get tweets that have been posted to your account. Refer to the Twitter shipping examples to see how the API operates. To access these examples, open the NI Example Finder by navigating to LabVIEW Help Find Examples. Then, select Browse according to: Directory Structure and open the LabVIEW Hacker folder, as shown in the figure below. The Post Tweet Finite.vi is a great starting point for a basic tweeting VI. Please note: these examples will not appear in the search, so make sure to browse according to directory structure!

Figure 7: NI Example Finder with Twitter Examples

Das könnte Ihnen auch gefallen