close
The Wayback Machine - https://web.archive.org/web/20140422112514/https://dev.twitter.com/discussions/16980

Create my own follow button

BinShao1
@BinShao1 Bin Shao

I would like to create a linked image and user can follow my site after clicking on it. Seems I cannot achieve this by using the standard solution: https://dev.twitter.com/docs/follow-button#using-an-iframe.

Is there other API's that I can use to achieve this? I would like to have whole control on the HTML markup (what user see), and then use some JavaScript calls to make user following my site without navigate away. Is this possible?

1 year 1 day ago

Replies

episod
@episod Taylor Singletary

See Web Intents -- there's a follow intent that just works like a standard anchor tag, with which you can mark up as you like.

52 weeks 21 hours ago
BinShao1
@BinShao1 Bin Shao

Thanks for the responds. The Web Intents requires user navigate to another page. Is there a solution to achieve all of the following?
1. use my own images and markup.
2. user does not need to navigate to other page. A user signed in will add follow immediately after one click (like the iFrame follow button).
3. A user not signed in will add follow after login (just like the iFrame follow button).

52 weeks 17 hours ago
benward
@benward Ben Ward

Hi Bin Shao,

Remember that with Web Intents you don't have to navigate the user away from your page, you can open them in a pop-up window over the top of your page.

If you want to have a custom, inline follow experience, you'll need to build an application using the OAuth API and have the user authorize your website (to do an inline follow a user needs to be authorized.)

Ben

52 weeks 17 hours ago
BinShao1
@BinShao1 Bin Shao

Thanks Ben. You are right, the user was not navigate away. It is a pop-up. I just want to have a "one click" experience for the users (just like the follow button with iFrame). Two follow up questions:

1) Seems that OAuth API is the only option for now to achieve this. For a user signed in, is it possible use the existing authentication?

For example, if a user already signed in to twitter (on twitter.com), is it possible I use the existing authentication on my site and add user as a follower without request the user to sign in again?

2) Do I need to contact Twitter to add my app to the allowed list (if it exist) before using the OAuth API?

Thanks,
Bin

52 weeks 16 hours ago
benward
@benward Ben Ward

A user doesn't need to log in again, but they do need to authorize your application to use their account. You only need to do that once, after which you store the access token credentials on your side.

You don't need to contact Twitter to use the API, just go to https://dev.twitter.com/apps to set one up and get your keys.

52 weeks 15 hours ago