/// <summary> /// Fetches all of the give object from the graph. /// </summary> /// <param name="facebook"></param> /// <param name="parameters">List of arguments.</param> /// <param name="ids">Ids of the objects to return.</param> /// <returns>A map from ID to object. If any of the IDs are invalid, an exception is raised.</returns> public static string GetObjects(this Facebook facebook, IDictionary <string, string> parameters, params string[] ids) { StringBuilder joinedIds = new StringBuilder(); for (int i = 0; i < ids.Length; i++) { if (i == 0) { joinedIds.Append(ids[i]); } else { joinedIds.AppendFormat(",{0}", ids[i]); } } if (parameters == null) { parameters = new Dictionary <string, string>(); } parameters["ids"] = joinedIds.ToString(); return(facebook.Get(null, parameters)); }
/// <summary> /// Gets the Facebook user id and the name who likes the specified Facebook object. /// </summary> /// <param name="facebook"> /// The facebook. /// </param> /// <param name="id"> /// The id. /// </param> /// <returns> /// Returns collection of Facebook users' id along with names. /// </returns> /// <remarks> /// Key: Facebook User Id /// Value: Facebook Username /// </remarks> public static BasicUserInfoCollection GetLikes(this Facebook facebook, string id) { var likes = facebook.Get <BasicUserInfoCollection>("/" + id + "/likes") ?? new BasicUserInfoCollection(); if (likes.Data == null) { likes.Data = new List <BasicUserInfo>(); } return(likes); }
/// <summary> /// Gets the the list of all facebook user who are members of the specified page. /// </summary> /// <param name="facebook"> /// The facebook. /// </param> /// <param name="pageId"> /// The page id. /// </param> /// <param name="parameters"> /// The parameters. /// </param> /// <returns> /// Returns list of users who are members for the page. /// </returns> public static BasicUserInfoCollection GetPageMembers(this Facebook facebook, string pageId, IDictionary <string, string> parameters) { var likes = facebook.Get <BasicUserInfoCollection>("/" + pageId + "/members", parameters) ?? new BasicUserInfoCollection(); if (likes.Data == null) { likes.Data = new List <BasicUserInfo>(); } return(likes); }
public ActionResult PostAuthorize(FacebookAuthenticationResult far) { if (far.IsSuccess) { var fb = new Facebook(far.AccessToken); // Use that access token to get the facebook user id var user = fb.Get <User>("/me", new Dictionary <string, string> { { "fields", "id" } }); // then save the access token FacebookMembershipProvider.LinkFacebook(User.Identity.Name, user.ID, far.AccessToken, far.ExpiresIn); // You may want to actually redirect instead for just returning view. // so that the users dont's see the ugly and confusing url like this one // http://localhost:30326/Facebook/PostAuthorize?code=8b2055447e53702722917_doMoY. // for simplicity i will just return a view. return(View("LinkSuccess")); } return(View("LinkError", far)); }
/// <summary> /// Fetches the give object from the graph. /// </summary> /// <param name="facebook">The facebook.</param> /// <param name="id">Id of the object to fetch.</param> /// <param name="parameters">List of parameters.</param> /// <typeparam name="T">Type of Object to deserialize to.</typeparam> /// <returns>Deserialized Facebook graph object.</returns> public static T GetObject <T>(this Facebook facebook, string id, IDictionary <string, string> parameters) where T : new() { return(facebook.Get <T>("/" + id, parameters)); }
/// <summary> /// Fetches the give object from the graph. /// </summary> /// <param name="facebook"></param> /// <param name="id">Id of the object to fetch.</param> /// <param name="parameters">List of parameters.</param> /// <returns>The facebook graph object.</returns> public static string GetObject(this Facebook facebook, string id, IDictionary <string, string> parameters) { return(facebook.Get("/" + id, parameters)); }
/// <summary> /// Fetches the connections for given object. /// </summary> /// <param name="facebook"></param> /// <param name="id">Id of the object to fetch.</param> /// <param name="connectionName">Name of the connection.</param> /// <param name="parameters">List of arguments.</param> /// <returns>Returns the connections.</returns> public static string GetConnections(this Facebook facebook, string id, string connectionName, IDictionary <string, string> parameters) { return(facebook.Get("/" + id + "/" + connectionName, parameters)); }
public ActionResult PostAuthorize(FacebookAuthenticationResult far) { if (far.IsSuccess) { var fb = new Facebook(far.AccessToken); // Use that access token to get the facebook user id var user = fb.Get<User>("/me", new Dictionary<string, string> { { "fields", "id" } }); // then save the access token FacebookMembershipProvider.LinkFacebook(User.Identity.Name, user.ID, far.AccessToken, far.ExpiresIn); // You may want to actually redirect instead for just returning view. // so that the users dont's see the ugly and confusing url like this one // http://localhost:30326/Facebook/PostAuthorize?code=8b2055447e53702722917_doMoY. // for simplicity i will just return a view. return View("LinkSuccess"); } return View("LinkError", far); }