我得到了解決方案如何回覆Facebook的私人信息。但這隻適用於Facebook粉絲頁面。
首先它需要有頁面的訪問令牌。然後點擊按鈕,把這段代碼:
var fb = new FacebookClient(lblToken.Text);
var query = string.Format(@"SELECT body,message_id,sender,participants, html_body, attachments FROM unified_message WHERE thread_id = 0 ");// and viewer_id = " + orligPage);//SELECT message_count FROM thread WHERE folder_id = 0
dynamic parameters = new ExpandoObject();
parameters.q = query;
dynamic results = fb.Get("551183598322481/conversations");//678999761//551183598322481
List<Refer.MyPage> q = JsonConvert.DeserializeObject<List<Refer.MyPage>>(results.data.ToString());
gvPageInbox.DataSource = q;
gvPageInbox.DataBind();
我需要這個gridview來檢索conversation_id。所以我們可以從c#頁面查看facebook上的conversation_id和消息。
這需要兩個文本框和一個按鈕後,從asp.net頁面回覆的談話: 代碼前端:
Body :
<asp:TextBox ID="txtBodyMsg" runat="server" Width="420px"></asp:TextBox>
which Conversation: <asp:TextBox ID="txtConversationID"
runat="server" Width="285px"></asp:TextBox>
然後在點擊按鈕把這個代碼:
protected void Button7_Click(object sender, EventArgs e)
{
var fb = new FacebookClient(lblToken.Text);
var to = new Dictionary<string, object>
{
{"id", "100000147534139"}
};
var jsonSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
var jsonTo = jsonSerializer.Serialize(to);
var commentDicitonay = new Dictionary<string, object>
{
{"id", txtConversationID.Text}, //plese enter full conversation ID// eg: t_mid.1395805167639:9ac20dbffcd33a5d13
{"message" , txtBodyMsg.Text},
{"to" , txtMsgTo.Text}
};
fb.Post("messages/", commentDicitonay);
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "Messages Replied!";
}