Share with Facebook in MVC 3 - c#

I'm developing an application online in MVC 3 who consists to manage a tennis club...
When a tennis player make a reservation for a tennis game, I would like to allow this tennis player to share his game with Facebook...
Is it possible ?
I have found that but no more...
Have you an idea or some tutorials ?
Thanks in advance

You could use the C# Facebook SDK. For example to post to the wall as shown in the documentation:
var fb = new FacebookClient("access_token");
dynamic result = fb.Post("me/feed", new { message = "My first wall post using Facebook C# SDK" });
var newPostId = result.id;

It can be done in many ways
You can use the graph api. (but i would recommend it for more complex interaction)
But the most simple one is to start sharing using the following url.
https://www.facebook.com/sharer.php?u=&t=
For details you can refer to Facebook documentations

There are 2 key ways in which you could achieve this:
Option 1 - Server-Side (Facebook for Websites)
Upon creation, your server could post to the users wall, if the user desires. This would be slightly more complicated to set-up, but would be more automated. You would need to set-up an app-id and ask the user to authenticate their facebook details.
Option 2 - Client-side (Facebook Share)
After creation, the user could be prompted with a Share or Like button, that would in turn post it to his or her wall. This would require the user an extra click, but would be more straight forward to set-up.

A Step by step tutorial is available here to integrate social plugin into mvc

Related

What are the ways to post a tweet to twitter with asp.net c#? [duplicate]

With Twitter's new OAuth interface, their API is now many times more complex than 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

Google Analytics from C#

My customer wants to track backend user's activity using google-analytics. He wants me to insert UserId in every URL of the backend. Backend is ASP.NET MVC3 and I tried to use routing for this purpose but without any luck.
I thought about more intellegent way to satisfy his need. So I'm thinking about calling google-analytics api from the server-side.
Is there an ability to do all that ga.js does but from c#?
Updated:
Customer wants to track user's activity using Google Analytics.
He wants me to add ?userId= to all links in backend.
So if I had /Category/Edit/123 now I have to change it to /Category/Edit/123?userId=456
Then I put ga.js to every page and customer tracks user's (456) activity.
I find the idea of using Google Analytics this way sucks but I have to implement some solution. The only thing I want is not to change urls but act with Google Analytics API from the server side.
Ok. Here is what think I actually needed:
1) Create Custim Dimension in Google Analytics console
Admin -> Custom Definitions -> Custom Dimensions -> New Custom Dimension -> userId
2) Modify my Google Analytics javascript and insert
var userId = #User.Id;
ga('set', 'dimension1', userId);
before ga("send", "pageview");
OR
use this solution
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id?hl=en

Is there a way to customize the Thinktecture.IdentityServer.v2 login page?

I'm using the Thinktecture.IdentityServer.v2 app to perform SSO for a couple of internal apps but would like to customize the login page for each application to have a smoother user experience. I can't seem to find a way to do that.
Can the login page be customized depending on the source application from where the client is comming?
"I can't seem to find a way to do that." - How hard have you tried? ;)
The RP has the extra data fields - so you can hang like a CSS name off the RP in the registration database. Further you can get to that RP data from the signin page - quoting the comment in AccountController:
// you can call AuthenticationHelper.GetRelyingPartyDetailsFromReturnUrl to get more information about the requested relying party
btw - IdentityServer's github repo has an issue tracker - you should use that for questions.
You can always have the RP pass a custom query string param and customize off of that. But you're outside the bounds of WS-Federation at that point. Plus, you must think about the nature of SSO -- the user is really signing into the IdP, not the app. So changing the IdP to look like the app is somewhat disingenuous.
I have solved this by customizing the SignIn.cshtml to adjust the style to what I need. Additionally, I have server side code in the top of SignIn.cshtml that does some string matching on the ReturnUrl (Request.QueryString["ReturnUrl"]). Then I show a different logo and header text based on some values I know to be unique for the different RP urls.
When upgrading to a new version of the ThinkTecture MVC, it will be a small job to update only this file to your specifics (just remember to have a copy of your modified SignIn.cshtml before you upgrade).

How to get twitter user timeline in C# using Twitterizer

i have the following code.
Twitter t1 = new Twitter("twitteruser","password");
TwitterUser user = t1.User.Show("username");
if (user != null)
{
TwitterParameters param = new TwitterParameters();
param.Add(TwitterParameterNames.UserID, user.ID);
TwitterStatusCollection t =t1.Status.UserTimeline(param);
}
In the above code, I want to get user timeline. I am using Twitterizer API. The twitter documentation for getting timeline of user is Here
I have checked the fiddler whats going on. In fiddler the request is :
http://api.twitter.com/1/direct_messages.xml?user_id=xxxxx
while i am expecting
http://twitter.com/statuses/user_timeline.format
Is anything left which i miss.
This is a bug in the latest version of the Twitterizer Library.
I will try to get this corrected and post an update today.
If you run into any other issues, please contact the Twitterizer group directly, on our site (http://www.twitterizer.net/) you'll find links to our mailing list, twitter account, and you can submit but reports directly to our team.
Ricky (Twitterizer founder)
Here's how to get a user's timeline without using oAuth or any authentication, for that matter:
UserTimelineOptions options = new UserTimelineOptions();
options.ScreenName = "SCREENNAME OF TWITTER USER";
TwitterStatusCollection tweets = TwitterTimeline.UserTimeline(options).ResponseObject;
I have to agree with Eric. I only looked at Twitterizer for a few hours, and I have not found one example that shows how to load a user's timeline without authorization.
Will I figure it out eventually? Yeah, I'll have to and I will; but it will take me forever.
The link that Ricky Smith gave (twitterizer.net) doesn't have this kind of simple example. The tutorials available on the internet that I found for twitterizer2, even those are not up-to-date and don't quite work or are missing information.
Ricky, how about being a lifesaver to me and others and showing us how to simply look at a user's public timeline, so there's no need for authorization? Whaddya'say?

i want to fetch facebook wall messages through c#

I’m able to post on wall, but I need to fetch Facebook wall messages through C#
==Update==
Now I’m getting wall messages, but now I want the messages with date.
You need the Graph API.
And to make a request to get the wall posts you need a extended permission on the authentication.
Facebook developer kit is your way to go...
Have you studied the FB API already or are you starting from scratch?
You can use Stream.Get to access wall posts, try reading the wiki:
http://wiki.developers.facebook.com/index.php/Stream.get
(You must have permission to access the users page of course)
I think there are many ways to do this, here is one example:
Make sure you have the permission "read_stream".
Then read all streams to get the messages on the wall;
var streams = API.Stream.Get(new List<long> { }, null, null, null);
streams.posts.stream_post.ForEach(post => Console.WriteLine(post.message));
'API' comes from your masterpage that has been inherited by Facebook.Web.CanvasIFrameMasterPage.
Responding to an old question, but i recently wrote a blog post on the same, i think it might help others who land to this question while Google search, read the post here (its using a custom built Facebook Connector)
click here to read
I want to do the same. Facebook API is changing and now it only returns few of the post even if you put LIMIT and UNTIL/SINCE parameters, so you have to change to FQL.
With FQL you can read stream table and get the posts made by the user and the post made by others in the walls's user.

Categories

Resources