Yortw / tweetmoasharp

TweetSharp is a fast, clean wrapper around the Twitter API.
Other
72 stars 22 forks source link

Action<TwitterStatus, TwitterResponse> action Method body does't execute. #60

Closed sharmarahul-ece closed 6 years ago

sharmarahul-ece commented 7 years ago

I am simply trying to post a tweet using SendTweet method, but its Action method is not executing. I am not able to figure out the reason. I have no idea where to look for the response and error..

Yortw commented 7 years ago

Hi,

Have you checked the Response property of the TwitterService object after the call completes (requires waiting for the async call to complete by using the async result)?

Have you tried using the synchronous version of the method that doesn't use a callback to see if you get an error (or a result in the Response property)?

Possibly posting some sample code would help people to diagnose the issue.

I just added the following test to my local copy of the repo, and it successfully posts the tweet and runs the callback using the latest Nuget package;

   [Test]
   public void Can_TweetWithCallback()
   {
      var service = GetAuthenticatedService();
      var status = _hero + DateTime.UtcNow.Ticks + " Tweet from TweetSharp unit tests";
      var callbackHappened = false;
      var asyncResult = service.SendTweet
      ( 
            new SendTweetOptions { Status = status }, 
            (cbStatus, cbResponse) =>
            {
                  callbackHappened = true;
            }
      );

      asyncResult.AsyncWaitHandle.WaitOne(); // Wait for the async op to complete

      Assert.IsTrue(callbackHappened);
      AssertResultWas(service, HttpStatusCode.OK);
      }
Yortw commented 6 years ago

Closing this as no response and it works for me, but please feel free to re-open if you have more info or a repro case/project. Thanks.