I'm trying to allow users to tweet a link from within my jQuery app. Basically, they create their own page, and then they select a number of social networks to share it on. On clicking 'Share', the app loops over the social network checkboxes, and posts to each, as selected.
I'm struggling to find a good way to do this for Twitter - everywhere I look online, I seem to get conflicting advice.
So, basically, what should happen is this:
- The user selects the 'Twitter' checkbox in my app, and hits 'share'.
- The app should then generate a url behind the scenes, and create a Tweet for the user's account.
- The user can then be shown a verification box from Twitter, if necessary (presumably they'll need to log in and verify the Tweet)
- The Tweet gets added to their Twitter feed.
It doesn't sound very complicated, but I can't find a way of doing it!
Edit
Thanks to the responses below, I've now got the following code:
var serverUrl = 'https://twitter.com/intent/tweet?url="www.rocketreel.com"&text="Test"';
$.ajax({
type: "GET",
url: serverUrl,
success: function(data) {
},
error: function(data) {
var obj = jQuery.parseJSON(data);
alert(obj.error);
}
});
Now when I run it, I get (in the console):
XMLHttpRequest cannot load https://twitter.com/intent/tweet?url=%22www.mysite.com%22&text=%22Test%22. Origin null is not allowed by Access-Control-Allow-Origin.
I'm not able to run it from the actual site at the moment, so am using localhost - is that why I'm getting this?