/// <summary>
        /// Posts on to Facebook Page
        /// </summary>
        /// <param name="postData">Data to be posted</param>
        /// <returns>Returns True: If posted successfully. 
        /// Exception: If post is unsuccessfull</returns>
        public bool AddPost(IFacebookPostData postData)
        {
            #region initialize objects and Url
                string accessToken = GetPageAccessToken();
                postData.AccessToken = accessToken;

                string path = string.Format("{0}/photos?access_token={1}", "MQ163", accessToken);
                dynamic publishResponse;

                FacebookClient fb = new FacebookClient();
                fb.AccessToken = this.AccessToken;
            #endregion

            publishResponse = fb.PostTaskAsync(path, postData.GetPostObject());

            // Wait for activation
            while (publishResponse.Status == TaskStatus.WaitingForActivation) ;

            // Check if it succeded or failed
            if (publishResponse.Status == TaskStatus.RanToCompletion)
            {
                string photoId = publishResponse.Result["post_id"];//post_id
                if (null != postData.TaggedUserEmail)
                {
                    bool result = TagPhoto(photoId, GetUserID(postData.TaggedUserEmail).Id);
                }
                return true;
            }
            else if (publishResponse.Status == TaskStatus.Faulted)
            {
                //CommonEventsHelper.WriteToEventLog(string.Format("Error posting message - {0}", (publishResponse.Exception as Exception).Message), System.Diagnostics.EventLogEntryType.Error);
                throw (new InvalidOperationException((((Exception)publishResponse.Exception).InnerException).Message, (Exception)publishResponse.Exception));
            }
            return false;
        }
Exemple #2
0
        /// <summary>
        /// Posts the messages and Picture to the MQ163 Feeds
        /// </summary>
        /// <param name="postData">Data to be posted</param>
        /// <returns>Returns True: If posted successfully. 
        /// Exception: If post is unsuccessfull</returns>
        internal bool AddPost(IFacebookPostData postData)
        {
            try
            {
                string accessToken = GetPageAccessToken();
                string albumID = GetAlbumID();
                var fb = new FacebookClient();
                postData.AccessToken = accessToken;

                string path = string.Format("{0}/photos?access_token={1}", albumID, accessToken);
                dynamic publishResponse;
                if (null != postData.TaggedUserEmail)
                    publishResponse = client.PostTaskAsync(path, postData.GetPostObject(GetUserID(postData.TaggedUserEmail).Id));
                else
                    publishResponse = client.PostTaskAsync(path, postData.GetPostObject(String.Empty));

                while (publishResponse.Status == TaskStatus.WaitingForActivation) ;
                if (publishResponse.Status == TaskStatus.RanToCompletion)
                    return true;
                else if (publishResponse.Status == TaskStatus.Faulted)
                {
                    throw (new InvalidOperationException((((Exception)publishResponse.Exception).InnerException).Message, (Exception)publishResponse.Exception));
                }
                return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// Posts the data on the page
 /// </summary>
 /// <param name="postObject">Data to be posted</param>
 /// <returns>Returns True: If posted successfully.
 /// Exception: If post is unsuccessfull</returns>
 public bool AddPost(IFacebookPostData postObject)
 {
     try
     {
         if (fbAgent.IsLoggedIn)
         {
             return(fbAgent.AddPost(postObject));
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
 /// <summary>
 /// Posts the data on the page
 /// </summary>
 /// <param name="postObject">Data to be posted</param>
 /// <returns>Returns True: If posted successfully. 
 /// Exception: If post is unsuccessfull</returns>
 public bool AddPost(IFacebookPostData postObject)
 {
     try
     {
         if (fbAgent.IsLogged)
         {
             return fbAgent.AddPost(postObject);
         }
         return false;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// Posts on to Facebook Page
        /// </summary>
        /// <param name="postData">Data to be posted</param>
        /// <returns>Returns True: If posted successfully.
        /// Exception: If post is unsuccessfull</returns>
        public bool AddPost(IFacebookPostData postData)
        {
            #region initialize objects and Url
            string accessToken = GetPageAccessToken();
            postData.AccessToken = accessToken;

            string  path = string.Format("{0}/photos?access_token={1}", "MQ163", accessToken);
            dynamic publishResponse;

            FacebookClient fb = new FacebookClient();
            fb.AccessToken = this.AccessToken;
            #endregion

            publishResponse = fb.PostTaskAsync(path, postData.GetPostObject());

            // Wait for activation
            while (publishResponse.Status == TaskStatus.WaitingForActivation)
            {
                ;
            }

            // Check if it succeded or failed
            if (publishResponse.Status == TaskStatus.RanToCompletion)
            {
                string photoId = publishResponse.Result["post_id"];//post_id
                if (null != postData.TaggedUserEmail)
                {
                    bool result = TagPhoto(photoId, GetUserID(postData.TaggedUserEmail).Id);
                }
                return(true);
            }
            else if (publishResponse.Status == TaskStatus.Faulted)
            {
                //CommonEventsHelper.WriteToEventLog(string.Format("Error posting message - {0}", (publishResponse.Exception as Exception).Message), System.Diagnostics.EventLogEntryType.Error);
                throw (new InvalidOperationException((((Exception)publishResponse.Exception).InnerException).Message, (Exception)publishResponse.Exception));
            }
            return(false);
        }
 public bool AddPost(IFacebookPostData postObject)
 {
     IsAddPostCalled = true;
     return(true);
 }
 public bool AddPost(IFacebookPostData postObject)
 {
     IsAddPostCalled = true;
     return true;
 }