0 Replies - 5587 Views - Last Post: 10 February 2012 - 05:04 PM

#1 dtrowell  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-February 12

WP7 facebook application, posting blank status updates only

Posted 10 February 2012 - 05:04 PM

Hi ive written a simple application for windows phone 7 that posts a status update to the users wall. This is all working correctly except for the fact that when the status update is done it is always empty. I am trying to make it so that the user can enter what they would like to say in a text box, but obviously so far this isnt working and all that is being sent is an empty status update. I am connecting to the facebook api and the authentication all works correctly or the post would not be sent at all, here is the status update code that I am working on:


private void PostStatusUpdate(string status, Action<bool, Exception> callback)
        {
            var request = HttpWebRequest.Create("https://graph.facebook.com/me/feed");
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.BeginGetRequestStream((reqResult) =>
            {
                using (var strm = request.EndGetRequestStream(reqResult))
                using (var writer = new StreamWriter(strm))
                {
                    writer.Write("access_token=" + _accessToken);
                    writer.Write("&amp;message=" + HttpUtility.UrlEncode(status));
                }

                request.BeginGetResponse((result) =>
                {
                    try
                    {
                        var response = request.EndGetResponse(result);
                        using (var rstrm = response.GetResponseStream())
                        {
                            var serializer = new DataContractJsonSerializer(typeof(FacebookPostResponse));
                            var postResponse = serializer.ReadObject(rstrm) as FacebookPostResponse;
                            callback(true, null);
                        }
                    }
                    catch (Exception ex)
                    {
                        callback(false, ex);
                    }
                }, null);
            }, null);
        }

        [DataContract]

        public class FacebookPostResponse
        {
            [DataMember(Name = "id")]
            public string Id
            {
                get;
                set;
            }
        }

        private void PostUpdate_Click(object sender, RoutedEventArgs e)
        {
            PostStatusUpdate(this.StatusText.Text, (success, ex) =>
            {
                this.Dispatcher.BeginInvoke(() =>
                {

                    if (success && ex == null)
                    {
                        MessageBox.Show("Status updated");
                        NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));
                    }

                    else
                    {
                        MessageBox.Show("Unable to update status");
                    }
                });
            });
        }




Has anyone encountered this before / know any solution to this problem?
Any insights into this would be much appreciated

Is This A Good Question/Topic? 0
  • +

Page 1 of 1