/// <summary> /// This method adds a comment to a post that was already published to a user's Wall. /// </summary> /// <example> /// <code> /// private static void RunDemoAsync() /// { /// Api api = new Api(new FBMLCanvasSession(Constants.WebApplicationKey, Constants.WebSecret)); /// api.Stream.AddCommentAsync(Constants.PostId1, "adding a comment (async)", AsyncDemoCompleted, null); /// } /// /// private static void AsyncDemoCompleted(string result, Object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="postId">The ID for the post to which you're adding the comment.</param> /// <param name="comment">The text of the comment. This is a plain text parameter only; you cannot format the comment with HTML or FBML.</param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>This call returns a comment_id if the comment was added successfully, or an error code if the call was unsuccessful.</returns> public void AddCommentAsync(string postId, string comment, AddCommentCallback callback, Object state) { AddCommentAsync(0, postId, comment, callback, state); }
/// <summary> /// This method adds a comment to a post that was already published to a user's Wall. /// </summary> /// <example> /// <code> /// private static void RunDemoAsync() /// { /// Api api = new Api(new FBMLCanvasSession(Constants.WebApplicationKey, Constants.WebSecret)); /// api.Stream.AddCommentAsync(Constants.UserId, Constants.PostId1, "adding a comment (async)", AsyncDemoCompleted, null); /// } /// /// private static void AsyncDemoCompleted(string result, Object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="uid">The user ID of the user adding the comment. If this parameter is not specified, then it defaults to the session user. Note: This parameter applies only to Web applications. Facebook ignores this parameter if it is passed by a desktop application.</param> /// <param name="postId">The ID for the post to which you're adding the comment.</param> /// <param name="comment">The text of the comment. This is a plain text parameter only; you cannot format the comment with HTML or FBML.</param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>This call returns a comment_id if the comment was added successfully, or an error code if the call was unsuccessful.</returns> public void AddCommentAsync(long uid, string postId, string comment, AddCommentCallback callback, Object state) { AddComment(uid, postId, comment, true, callback, state); }
private string AddComment(long uid, string post_id, string comment, bool isAsync, AddCommentCallback callback, Object state) { var parameterList = new Dictionary<string, string> { { "method", "facebook.stream.addComment" } }; Utilities.AddOptionalParameter(parameterList, "uid", uid); Utilities.AddOptionalParameter(parameterList, "post_id", post_id); Utilities.AddOptionalParameter(parameterList, "comment", comment); if (isAsync) { SendRequestAsync<stream_addComment_response, string>(parameterList, uid <= 0, new FacebookCallCompleted<string>(callback), state); return null; } var response = SendRequest<stream_addComment_response>(parameterList, uid <= 0); return response == null ? null : response.TypedValue; }