POSTing from a batch process


#1

(To preempt any concerns with what I’m about to discuss… As per “Automation Rules and Best Practices” https://support.twitter.com/articles/76915, I have extensively disclosed (and exposed) my proposed application with Twitter support, and was told that “you should be fine.” (And, subsequently, “We look forward to seeing what you develop.”))

I’m developing an app through which I intend to publish news items to multiple Twitter accounts from an automated, non-interactive batch process. The same specific accounts will be published to each day (known quantity/identity), with new accounts being added over time, but existing accounts rarely if ever eliminated.

I created a test Twitter Application, revealing the Consumer key/Consumer secret and Access token/Access token secret necessary to publish to my test account (which I have successfully done).

If I understand this correctly, I would use the same Consumer key/secret when publishing to each account, but a unique Access token/token secret for each account. How do I determine the token/token secret for the other accounts that I will publish to? Will the token/token secret be “permanent”, or will they change with each batch run (or even with each POST)?

Or do I have to create a unique Twitter Application for each account that I wish to publish to? (Which, while painful to initially set up, will be trivial to implement in the batch process.)

Or am I fundamentally misunderstanding Twitter Applications? I’ve looked at the “Which authorization path should I choose?” document, but (being new to Twitter) it’s a little opaque to me at this point. Does the batch nature of the process necessitate that I become intimately familiar with oob?

Thanks for your help!


#2

Does other library also have the same problem?
If no, maybe I have to give them a try…


#3

Hi Michael,

If you’re wanting to post to multiple accounts in a batch process, you’ll only need one application record to do it. You could use a single app for each account, but like you said, that’d be a bit of work.

However, there’s still a bit of work you’ll need to do for a single application with multiple users as well.

An access token represents a relationship between an application and a specific user account. When you create an app on dev.twitter.com, we give you the convenient opportunity to automatically create an access token representing your user account in associated with your own app. This makes it really easy to get started with a single user account and an application. Access tokens don’t expire on their own and can be re-used indefinitely – or until the access is deliberately revoked or altered.

But once you need to add more users, things get a little more complicated. You’ll need to invoke the OAuth flow to negotiate an access token for each user that you want to post on behalf of. (You’ll also want to make sure your app is setup for read-write permissions). This process is described in the [node:115] docs. The command-line Twurl tool can make this process a little easier if you need help. https://github.com/marcel/twurl


#4

@episod - thanks for the reply (and sorry for the delay)!

I’ve figured out what I need to do - one twitter app, authorized by each of my user accounts. I also created a “stub” authorization app (on my side) that initiates the OAuth process with twitter and stores the resulting user token/secret in my database.

Now I just have to create/confirm/authorize all of the user accounts, at which point my batch process will have what it needs to publish.


#5

I have a related question. I’m building an integration with Twitter and have an issue with the current method of user opt-in. The integration is from Force.com and the issue is that I might want to notify literally thousands of users at once that they are invited to permit the two clouds to talk with each other.

It’s no problem to direct a user - who is currently logged into my application - through the OAuth dance. But what if I want to post to a community of thousands that this new integration is available and that they can sign up for it - without having to already be logged into my Force.com app?

Part of the issue is that these community members have lean/inexpensive log ins to Salesforce that do not come with full functionality and currently this has to be done by an administrator. The application already integrates with Facebook and the same issue exists there as well.

Thanks in advance for any advice/help on this!