开发者

Simplest Method to Send Twitter Tweet and Facebook Status

开发者 https://www.devze.com 2023-01-31 08:07 出处:网络
With Twitter\'s new OAuth interface, their API is now many times more complex t开发者_StackOverflowhan what it was. And I haven\'t even looked at Facebook\'s API yet.

With Twitter's new OAuth interface, their API is now many times more complex t开发者_StackOverflowhan what it was. And I haven't even looked at Facebook's API yet.

What I'm wondering if there is a method that employs some higher-level, existing code or interfaces to make this a simpler task.

All I want to be able to do is initiate a Twitter tweet or Facebook share on the user's behalf and be able to control the initial text of those messages, from an ASP.NET application.

I found some similar questions on SO, but they had no answers.

EDIT: I know there are things like AddThis and ShareThis, but I need something that will give me control over the default message. It must contain a link with a code that is specific to the current user.


Twitter Integration...

For making Tweets from an ASP.NET application on users' behalf, check out Twitterizer. It's a free, open-source project for integrating with Twitter from .NET applications.

I agree that using OAuth can be a bit daunting, but the Twitterizer API wraps up most of the complexity. I've written an article on using Twitterizer in an ASP.NET application that you may be interested in: Integrating Twitter Into An ASP.NET Website Using OAuth. After reading the article, download the code sample at the end, which is a working demo showing how to use Twitterizer to post a tweet from an ASP.NET website.

Facebook Integration...

For integrating with Facebook, chcek out the Facebook Developer Toolkit. Like Twitterizer, it's an open-source, free API and should get you going in the right direction.

Happy Programming!


After looking around for a while, I found sharethis.com. They have various share buttons you can add to your site that send Twitter tweets, Facebook shares, etc.

It looks like it also supports options to control the URL, so I could modify this to include whatever URL I need.

I haven't yet figured out if I can control the default message text. I'm looking into that.

But it seems like this is probably the simplest way to accomplish what I want.


This is probably what you're after for twitter: https://twitter.com/about/resources/buttons#tweet

Let's you configure a button (or URL to redirect to) that starts the user off with some default text. The user can change the text before they post.

Don't know about facebook.


Twitter Integration:

Check this code and link/article simple and easy :

protected void btnTweet_Click(object sender, EventArgs e)
{
 string oauthAccessToken = Session["twtoken"].ToString();
 string oauthAccessTokenSecret = Session["twsecret"].ToString();

 OAuthHelper oauthhelper = new OAuthHelper();
 oauthhelper.TweetOnBehalfOf(oauthAccessToken, oauthAccessTokenSecret, txtTweet.Text);

 if (string.IsNullOrEmpty(oauthhelper.oauth_error))
      Response.Write("Twit Posted Successfully");
 else
      Response.Write(oauthhelper.oauth_error);
}

Read more how to get access token and secret key and download OAuthHelper and OAuthUtility Class below is the link -

How to post tweet on behalf of an user from asp.net using oauth authentication

Login with twitter using oauth authentication in asp.net and get access token, screen name and userid

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号