The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
How to tweet from RM
homero_merino
Member Posts: 5 Contributor I
Hi community,
I want to know if there's a way to post a tweet from a RM process. I want to automate a "posting" process, and want to know if it is possible to reuse the same connection used to access Twitter.
If it's not possible, what do you recommend? I was thinking as an alternative option to use Twython inside a Python script. However, I would prefer to use my current's Twitter connection instead of hardcoding in the script the OAUTH_TOKEN or OAUTH_TOKEN_SECRET.
Any PRO suggestion for this? Thanks in advance!
Kind regards,
Tagged:
0
Answers
Here's a link to a video with the Twython setup you propose by the amazing Thomas Ott.
https://www.neuralmarkettrends.com/using-python-with-rapidminer/
Edit: or it would be if the video was still up. @Thomas_Ott can you help?
As far as the video, I did that when I was part of RapidMiner so they uploaded it. I would check with @sgenzer to see if if it's still up there.
I used the Execute Program operator to do this because it was before the Execute Python operator was created. See below for the XML. I can't find the Python code anymore but if I remember correctly it used the sample Twython script to post a Tweet, except I dropped in the macro as part of the Tweet body.
hi @homero_merino - you're right. It should be a fifth Twitter operator ("Send Tweet" or something like that). They're all just calls to the Twitter API anyway. If you want I can probably play around and figure out how to do this with Enrich Data via Webservice, or if OAuth2 gives me a hard time, shell scripting using Execute Program (cURL). I've done both before with other APIs.
Scott
Hi Thomas,
Thank you for your reply.. actually your Python code looks like the one I was wondering to implement; thank you for it.
I need to tell you that you left the app_key, app_secret, oauth_token & oauth_token_secret params set on your process. I think you should edit your post to avoid unauthorized accesses. That's the reason why I don't like a lot the script solution... 'cause these access params go hardcoded and it's easy for anyone to see them but, well I think it is the only way right now.
Thanks a lot! Kind regards,
Yeah that OAuth stuff is old, it doesn;t work anymore. I hope.
To avoid hardcoding the auth tokens in your script you can pass them in as macros using the Execute Python operator.
The values of the macros can be stored in a database table (encrypted) which you provide access to only to the authorized users.
(Store the data in the database encrypted for added security).
This has the added advantage of making the process portable as you can store multiple auth tokens in the same table (or set of tables) and then only use the one. It still means that the tokens can be extracted if the person puts in the right amount of effort, but is much more difficult. You can also use RapidMiner Server to authorize access to the table with the credentials in and even serve certain tables to certain login users. However, the easiest way is for a future Send Tweet operator to come in.
oh huh that's pretty clever, @JEdward. Do you have a sample you can share here?
Scott
My suggestion would've been to macro the OAuth keys but @JEdward beat me to it.