Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Twitter API for LabVIEW

Introduction:


Twitter.com has changed their authentication requirements and now requires the use of OAuth protocol.  This change rendered the previous Twitter API for LabVIEW nonfunctional.  This new Twitter API fully supports the OAuth protocol now required by Twitter.com.

Steps to Complete:

  • Sign up for a Developer Account at dev.twitter.com

          In order to programmatically access Twitter's interface, you must first sign up for a Developer Account at dev.twitter.com.


  • Obtain your Credentials

          Once you have a Developer Account, you will need to Create an App from the Twitter side.

Create_APP.png         

This will require you to give your application a name (i.e. "ACME LabVIEW API") and put down some basic information about the application.  It will also require you to accept Twitter's Developer user agreement.

Once your App is created you will be able to view you App's unique Consumer credentials.  These are used so that Twitter can identify your App.  You will also be able to create an Access Token that will identify your user account to your application.

Credentials.png

You will need these credentials to operate the Twitter API.

  • Install the VI Packages

There are two packages (attached to this page) that will need to be installed in order to operate the Twitter API.  The first implements the OAuth protocol for Twitter.  Unfortunately, at this time most websites require a slightly different implementation of OAuth, so this library of VIs will not work with other sites requiring OAuth authentication.  However, the API should require minimal modifications in order to function with other websites.  The second package adds a Twitter API that utilizes the OAuth API.

Installation of both packages requires JKI's VI Package Manager.

  • Run the Example Programs

The VI Packages install ready-made examples onto your computer.  You can find them through the NI Example Finder under the Twitter directory.

Examples.png

These examples will require the credentials obtained from dev.twitter.com.

Additional Notes:

This API could not have been completed and utilizes the work of Ton Plomp and his LabVIEW encryption library, freely available here.

The VI Packages require LabVIEW 2010 or later.

There is one known issue: Tweets with the +, &, or = characters will fail authentication.  These characters appear to be percent encoded properly, but Twitter seems to disagree.

Applications Engineer
National Instruments
Comments
travispape
Member
Member
on

Chris,

What would it take to get this to work on the Mac platorm?  Using an external browser for authorization and getting the PIN is no problem.  I'm running into problems with the httpClient library.  What is confusing to me is the VIs exist on my Mac platorm installation of LabVIEW 2010, but the httpClient:OpenHandle.vi always throws an error.

Travis

Chris V
NI Employee (retired)
on

What error are you running into?  Can you run a simple VI that opens a handle, performs an HTTP GET (on say google.com), and then closes the handle?  Does that also throw an error?

Nothing aside from the LabVIEW VIs themselves should be specific to the Mac platform.  HTTP protocol is the same throughout.

Applications Engineer
National Instruments
travispape
Member
Member
on

It looks like the httpclient library don't actually work on LabVIEW 2010.  My issue seems to be similar to this:  http://forums.ni.com/t5/LabVIEW/get-HTTP-on-LabVIEW-2010-for-Mac/td-p/1485774

Just like the original poster, I was getting the error 7 at first.  If I create the shortcut as mentioned in the solution post, I can avoid error 7; however, I'm getting a new error 74 now:

Call Library Function Node in LabVIEWHTTPClient.lvlib:OpenHandle.vi:4->OAuth.lvlib:Request Token.vi->OAuth.lvlib:Get Pin Access.vi->Twitter API.lvlib:Login - Pin.vi->Twitter API.lvlib:Get Users Page.vi

I am going to have to deploy this to many Mac customer's computers.  The httpclient library vis are password protected, so I'm not able to debug what is going on.  As someone mentioned on the thread (JohnCS, just before the "solution"), it is a shame that GET & POST VIs are not written in more vanilla code.  Would it be possible to modify your code to use the more basic TCP library?

Chris V
NI Employee (retired)
on

Absolutely.  Under the hood they are all just TCP, so if you can implement the the GET & POST functionality it should be fine.

FYI, the Open Handle is only needed so that header information can be added to the request.  If you can add this without the Handle, you should be able to just use the GET and POST VIs in LabVIEW.

Applications Engineer
National Instruments
travispape
Member
Member
on

Ok, aside from the fact that I don't really know that much about Get and Post and if I modify your code I would be messed up the next time you post a VI Package update....

What about the fact that SSL is not supported on Mac LabVIEW 2010?  It is discussed in the 3rd page of the thread I linked above.  What layer does that pertain to?  Would that be yet another show-stopper for Mac folks?

And remember this about Mac folks:  http://www.macrumors.com/2011/07/13/apple-soars-to-third-place-in-u-s-pc-market-with-10-7-share/  At some point NI is going to have to remember that they started out as a Mac company.  🙂

Travis <---<<< LabVIEW developer since version 2

Chris V
NI Employee (retired)
on

No SSL in the API.

Applications Engineer
National Instruments
travispape
Member
Member
on

What about all the HTTPS URLs?

Chris V
NI Employee (retired)
on

Sorry, just meant you didn't need the SSL.vi.

Applications Engineer
National Instruments
travispape
Member
Member
on

I'm dummer than you think I am.  🙂

In the thread above, NI guy Charles K wrote:

Are you using "https" as your protocol?  Unfortunately, in LabVIEW 2010, we are not authorized to support https (a.k.a. SSL encryption) on Mac and Linux.

So that would be the show-stopper for me on the Mac even if I figure out how to implement GET and POST in TCP, right?

Travis

Chris V
NI Employee (retired)
on

Unfortunately, it sounds like it.

Applications Engineer
National Instruments
travispape
Member
Member
on

Did SSL support for Mac get added to LabVIEW 2011?  I've been searching around, but I can't find the answer.

Niuxx
Member
Member
on

My VI can successfully verify credentials programmatically, but whenever I use a local variable or a queue to pass the data in my tweets, it fail to update status.

Any idea why?

I have Labview 2011 student.

Thanks a lot.

Niuxx
Member
Member
on

I tried using just string constants in my tweet, it works perfectly every single time.

Trella
Member
Member
on

Hi! When trying to tweet "with user login" i get the following error:
Unbenannt.jpg

when trying to tweet with tokens the same problem occurs. What am i doing wrong? DNS, Ping, Inet-Connection everything is fine.

Trella
Member
Member
on

It looks like Twitter has ended XML support on its API and is now only supporting JSON. It would be nice if someone could update the Twitter VIs to support this new API.

Christian_L
Active Participant
Active Participant
on

Hello Trella,

There is another Twitter API available for LabVIEW and it includes JSON support. Please take a look at the tools available at https://decibel.ni.com/content/groups/interactive-internet-interface-twitter-toolkit-for-labview

Make sure to read the Getting Started information

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
Trella
Member
Member
on

Unfortunately their Twitter Example VI is still using the old REST and not JSON and therefore it is not working anymore. There is a JSON Toolkit, but i need an working example for tweeting with LabVIEW. Is someone able to do this?

Trella
Member
Member
on

Could please someone test it and tell me if he is still able to tweet?

Contributors