2011-11-04 89 views

回答

1

的Facebook不允許SDK發送私人信息,防止誤操作垃圾郵件發送者

0

這是用於發送消息..

使用Facebook C#SDK(http://facebooksdk.codeplex.com)

var app = new FacebookApp("access_token"); 
var parameters = new Dictionary<string, object>(); 
parameters["message"] = "This is a test message"; 
app.Api("/me", parameters, HttpMethod.Post); 

這將發佈一條消息到當前用戶的壁。您也可以使用該SDK發佈圖像。有關如何做這些測試的樣本。請注意,如果你的意思是你想給他們發送私人消息,而不是在他們的牆上張貼這是不可能的。 Facebook不允許應用程序直接向用戶發送消息。

+0

你好我的意思是私人消息!如何閱讀私人信息? –

+0

因此,如果Facebook不允許發送私人消息,微軟發佈的Facebook應用程序如何[鏈接](http://www.windowsphone.com/fr-FR/apps/82a23635-5bd9-df11-a844-00237de2db9e)是能夠發送/閱讀私人信息? –

+1

我在facebook FQL [link](https://developers.facebook.com/docs/reference/fql/message/)中發現了這個,我認爲它很重要!它顯示瞭如何從MESSAGE表中檢索信息。我怎樣才能做到這一點與facebbok-c#-sdk? –

3

要訪問消息(聊天的)u必須有read_mailbox擴展權限(我認爲),不喜歡:

string facebookToken = "your facebook token here"; 
var client = new FacebookClient(facebookToken); 

dynamic result = client.Get("me/inbox", null); 

foreach (dynamic item in result.inbox.data) 
{ 
    //item is a conversation 
    //the latest updated conversations come first so 
    //im just gona grab the first conversation with unreaded/unseen messages 

    if (item.unread > 0 || item.unseen > 0) 
    { 
     string conversationID = item.id; 
     string otherPerson = item.to.data[1].name;//the item.to.data[0] its myself 

     //you can access the messages of the conversation like 
     //by default it will return the last 25 messages, u can get more, by making a call too 
     //"https://graph.facebook.com/{0}/comments?limit={1}" like: 
     //dynamic result = client.Get(string.Format("{0}/comments?limit={1}",conversationID, 100), null); 
     foreach (dynamic message in item.comments.data) 
     { 
      //Do want you want with the messages 
      string id = message.id; 
      string fromName = message.from.name; 
      string fromID = message.from.id; 
      string text = message.message; 
      string createdDate = message.created_time; 
     } 

     //To send a message in this conversation, just 
     dynamic parameters = new ExpandoObject(); 
     parameters.message = "A message from code!"; 
     client.Post(string.Format("{0}/comments", conversationID), parameters); 
     //or 
     //client.Post(string.Format("{0}/comments", conversationID), new Dictionary<string, object> { { "message", "A message from code!" } }); 

     //NOTE!! - The application must be on white list for you te be able to post a message 
     // read - https://developers.facebook.com/docs/ApplicationSecurity/ 

     break; 
    } 
} 

您可以在https://developers.facebook.com/tools/explorer

更多的嘗試:

Inbox NotificationsMessage Info

變化:coming soon changes

希望它幫助;)

1

這是怎麼使用C#來顯示收件箱,asp.net:

protected void Button4_Click(object sender, EventArgs e) 
{ 
    var fb = new FacebookClient(lblToken.Text); 

    var query = string.Format(@"SELECT message_id, author_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0)"); 

    dynamic parameters = new ExpandoObject(); 
    parameters.q = query; 
    dynamic results = fb.Get("/fql", parameters); 

    List<MyMessage> q = JsonConvert.DeserializeObject<List<MyMessage>>(results.data.ToString()); 

    GridView4.DataSource = q; 
    GridView4.DataBind(); 

} 
相關問題