Question

I am having a hard time solving this dilemma, and I have a feeling that it's been done a million times, I just cannot find any documentation on it. What I am trying to do:

I have a button on my site that pops open a Twitter window and allows a user to tweet a reformatted message that I have defined.

<a onclick="window.open('https://twitter.com/intent/tweet?original_referer=<?php echo $_page_url?>&source=tweetbutton&text=<?php echo $tweet_message ?>&url=<?php echo $_page_url?>', '', 'height=500,width=650,modal=yes,alwaysRaised=yes resizable=1 scrollbars=1');">
<img src="/share/twitter_share.png" alt="share now" width="94" height="23" />
</a>

What I am needing is a way of tracking if this person has successfully tweeted this message and the user id or username returned for storage in a database. The reason for this is that I want them entered in this database ONCE. We are having a giveaway based on a single share/tweet, and they only get one entry per username/id.

I have tried multiple ways to retrieve the ID or username of current logged in user, mostly using the https://api.twitter.com/ to return JSON to no avail. I have also read the following:

https://dev.twitter.com/docs/platform-objects/users

https://dev.twitter.com/docs/platform-objects/tweets

And am now stuck. All I need is a return for user id that I can attach to the above window. Does anyone know how I can accomplish this? Thanks!

Was it helpful?

Solution

It cannot be done using this approach, at least not with true certainity. All you can do is track if 1) the window was successfully open using onclick and 2) if the window was closed (you can assume that perhaps the user completed the tweet).

You will NOT able to get ANY information from you open window via Javascript because the window is NOT in your domain (meaning, it is not on your server but on Twitter's).

What you want to do is implement this functionality in code as opposed to a javascript popup window. I have seen a number of commerical products that do exactly what you are describing.

The documentation (links) you provided refer to the REST API for Twitter (which usually works on the server) that is VERY different from Twitter's Web Intents which is client site javascript plugin, which has no similar API.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top