Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8633899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:35:03+00:00 2026-06-12T09:35:03+00:00

I am using Facebook.dll i.s FacebookClient , Mainly I want to read Facebook user

  • 0

I am using Facebook.dll i.s FacebookClient , Mainly I want to read Facebook user mail box I have auth token saved in db.

  1. Select messages (all) from mail box where I can mention start date and end date
  2. Save all messages in db

I have used

dynamic result = objFacebookClient.Get("fql",
                     new { q = "SELECT message_id, author_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0)" });

Is it possible get result as

  • Message – Content of message
  • Send t o- Sender name and id
  • Receive By – Name and id
  • Create Date – Message create date

Code is here

dynamic result = objFacebookClient.Get("fql",
   new { q = "SELECT message_id, author_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0)" });
List<Model.FacebookUserMessageInfo> objFacebookMessageList = new List<Model.FacebookUserMessageInfo>();
if (result != null)
{
    Model.FacebookUserMessageInfo objFacebookMessage = null;
    var values = result.Values;
    var TotalResult = (((System.Collections.Generic.Dictionary<string, object>.ValueCollection)values).ToList()[0]);
    var TotalMessagesData = (JsonArray)TotalResult;
    if (TotalMessagesData != null)
    {
        foreach (var Messages in TotalMessagesData)
        {
            objFacebookMessage = new Model.FacebookUserMessageInfo();
            objFacebookMessage.MessageText = (((JsonObject)Messages)["body"]).ToString();
            objFacebookMessage.ActionUserID = Convert.ToInt64(((JsonObject)Messages)["author_id"]);
            if (objFacebookMessage.ActionUserID == CurrentUserId)
            {
                objFacebookMessage.MessageType = Core.Enum.FacebookMessageType.Sent.ToString();
            }
            else
            {
                objFacebookMessage.MessageType = Core.Enum.FacebookMessageType.Receive.ToString();
            }
            objFacebookMessage.FacebookUserId = FacebookUserId;
            var MessageSecond = (((JsonObject)Messages)["created_time"]).ToString();
            var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
            objFacebookMessage.CreatedDate = dateTime.AddSeconds(double.Parse(MessageSecond));
            objFacebookMessageList.Add(objFacebookMessage);
        }
    }
}

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:35:05+00:00Added an answer on June 12, 2026 at 9:35 am

    I got my solution

    public class Facebook
    {
        #region Private Properties
    
        private string ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"];
        private string ClientSecret = System.Configuration.ConfigurationManager.AppSettings["ClientSecret"];
    
        #endregion
    
        #region Public Methods
    
        public string GetLongLifeAccessToken(string ExistingToken)
        {
            try
            {
                string Data = string.Empty;
                string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&client_secret={1}&grant_type=fb_exchange_token&fb_exchange_token={2} ",
                                ClientId, ClientSecret, ExistingToken);
                System.Net.HttpWebRequest request = System.Net.WebRequest.Create(url) as System.Net.HttpWebRequest;
                using (System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse)
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
                    Data = sr.ReadToEnd();
                    Data = HttpUtility.ParseQueryString(Data)["access_token"];
                }
                return Data;
            }
            catch (Exception ex)
            {
    
                throw new Exception(ex.Message);
            }
    
        }
    
        public List<Model.FacebookUserMessageInfo> ReadFacebookMailbox(string AuthToken, long? CurrentUserDefaultFacebookId, DateTime? LastProcessedDate, DateTime CurrentDate, int FacebookUserId)
        {
            try
            {
    
                FacebookClient objFacebookClient;
                List<Model.FacebookUserMessageInfo> objFacebookMessageList;
                objFacebookClient = new FacebookClient(AuthToken);
                try
                {
                    objFacebookClient.Get("me");
                }
                catch (Exception ex)
                {
                    throw new Exception(ErrorType.UnableToAuthorizFacebookUser.ToString());
                }
                TimeSpan t = LastProcessedDate.Value - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                int timestamp = (int)t.TotalSeconds;
    
                dynamic result = objFacebookClient.Get("fql",
                   new { q = "SELECT message_id, author_id, viewer_id, body, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0) AND created_time >= " + timestamp.ToString() });
                objFacebookMessageList = new List<Model.FacebookUserMessageInfo>();
                if (result != null)
                {
                    Model.FacebookUserMessageInfo objFacebookMessage = null;
                    var values = result.Values;
                    var TotalResult = (((System.Collections.Generic.Dictionary<string, object>.ValueCollection)values).ToList()[0]);
                    var TotalMessagesData = (JsonArray)TotalResult;
                    if (TotalMessagesData != null)
                    {
                        foreach (var Messages in TotalMessagesData)
                        {
                            /*author_id =   The ID of the user who wrote this message.*/
                            /*viewer_id =   The ID of the user whose Inbox you are querying*/
                            objFacebookMessage = new Model.FacebookUserMessageInfo();
                            objFacebookMessage.MessageText = (((JsonObject)Messages)["body"]).ToString();
                            long author_id = Convert.ToInt64(((JsonObject)Messages)["author_id"]);
                            long viewer_id = Convert.ToInt64(((JsonObject)Messages)["viewer_id"]);
                            if (author_id == viewer_id)
                            {
                                objFacebookMessage.MessageType = Core.Enum.FacebookMessageType.Sent.ToString();
                            }
                            else
                            {
                                objFacebookMessage.MessageType = Core.Enum.FacebookMessageType.Receive.ToString();
    
                            }
                            objFacebookMessage.ActionUserID = author_id;
                            objFacebookMessage.FacebookUserId = FacebookUserId;
                            var MessageSecond = (((JsonObject)Messages)["created_time"]).ToString();
                            var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                            objFacebookMessage.CreatedDate = dateTime.AddSeconds(double.Parse(MessageSecond));
                            objFacebookMessageList.Add(objFacebookMessage);
                        }
                    }
    
                }
                if (objFacebookMessageList.Count > 0)
                {
                    objFacebookMessageList = objFacebookMessageList.Where(fm => fm.CreatedDate >= LastProcessedDate && fm.CreatedDate <= CurrentDate).ToList();
    
                    objFacebookMessageList.ForEach(item =>
                    {
                        var Auther = objFacebookClient.Get("https://graph.facebook.com/" + item.ActionUserID.ToString());
                        if (Auther != null)
                        {
                            item.ActionUserName = ((JsonObject)Auther)["name"].ToString();
                        }
                        else
                        {
                            item.ActionUserName = null;
                        }
                    });
    
                }
                return objFacebookMessageList;
    
    
    
            }
            catch (Exception ex)
            {
    
                throw new Exception(ex.Message);
            }
    
        }
    
        #endregion
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to post to user wall in facebook using Facebook.dll in WP7. I found
I'm using Facebook Connect along with the Facebook Graph API to fetch user's email
I am using facebook PHP SDK. After the user allows my application, facebook redirects
I am using Facebook Connect for sharing something on my appliction. So I want
I'm using Facebook Connect's Comments Box ( http://wiki.developers.facebook.com/index.php/Comments_Box ) to handle comments on my
I'm using Facebook Likes in my site. I have a gallery page which shows
i am using facebook api in my android project {error:{type:OAuthException,message:Error validating access token: Session
I am using Facebook comment box plugin: <fb:comments href=${myPageUrl} num_posts=20 width=630></fb:comments> Every thing is
I am doing login using facebook section of my iphone app. I want to
I am using Facebook PHP SDK to authenticate the user. After generating the LoginUrl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.