3

For a twitter application with PHP I need to get access tokens for users with the following details:

  • Shouldn't expire (I want to use the access tokens while the users are offline)
  • Read / Write access (DMs aren't necessary)
  • I don't have to authenticate again if I have the access token

How do I get an access token from twitter with those specifications?

  • 3
    Check this answer http://stackoverflow.com/a/6332722/1606729 and this https://dev.twitter.com/docs/auth/tokens-devtwittercom – koopajah Feb 05 '13 at 17:38
  • First link is cool, thanks. Second link is only for one user I believe, I need several users. Ideas? –  Feb 05 '13 at 17:40
  • When the user logs in with twitter on your application and give you access you should receive both OAuth tokens as explained in first post. You then need to store then somewhere and use these whenever you want to tweet as a specific user. – koopajah Feb 05 '13 at 17:42
  • The problem is [there are several ways for obtaining access-tokens](https://dev.twitter.com/docs/auth/obtaining-access-tokens) and I have no idea which to use and how. Do you? Or do you have a link to good explanation? –  Feb 05 '13 at 17:44
  • The link you provide describe several explicit cases. You should update your question with more details about what you do. Is it a web application? Will user log onto your application with their twitter account and you will require write access? – koopajah Feb 05 '13 at 17:46
  • 1
    In the end it will be a standalone script using the access token stored in a database to post a tweet. So it's not possible to authenticate on the moment the script is executed, that's why I need to store the access tokens. And yes I do require write access as I want to post tweets. So the user logs in one time and after that the script can use the account to tweet whatever the script wants. –  Feb 05 '13 at 17:48
  • Camil > ok but update your question accordingly for other people to understand what you need. And I don't see the issue, you will obtain the OAuth secret when the user register with his twitter account and save them. Then you will be able to tweet for him. – koopajah Feb 05 '13 at 17:58
  • I will update it in a minute. The question now is: how do I obtain the access token the right way for this application? –  Feb 05 '13 at 18:02
  • Ok, I'd say to use this type of flow : https://dev.twitter.com/docs/auth/3-legged-authorization – koopajah Feb 05 '13 at 18:18
  • Very well, you can make that an answer. Can you give me an explanation of the requests that are needed too? –  Feb 05 '13 at 18:19

1 Answers1

2

For Twitter, based on this document you need the 3-legged OAuth

These documents already provide the list of steps you must follow to ask for the proper OAuth token. I can't detail more than what is written as I'm using Janrain in my current own project.

koopajah
  • 23,792
  • 9
  • 78
  • 104
  • I don't know why twitter API documentation make me confused. Bring me for one page to another page and then give more canfusion. – Ari Mar 13 '14 at 01:10