开发者

Unable to post multiple tweets synchronously

I'm working on posting some information to a twitter account via MGTwitterEngine. The string ends up being more then 140 characters and needs to be broken into multiple tweets. However, it seems the post request does this in an asynchronous manner. This means that if I call the following:

SA_OAuthTwitterEngineengine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: loginDelegate];
engine.consumerKey = kOAuthConsumerKey;
engine.consumerSecret = kOAuthConsumerSecret;
[engine sendUpdate:@"Message1"];
[engine sendUpdate:@"Message2"];
[engine sendUpdate开发者_Go百科:@"Message3"];

Does not post in the correct order. I can recieve the tweets in the order: Message2, Message3, Message1.

Even if there's a multiple minute pause between the sendUpdate message requests (via the debugger tool and through sleep()), MGTwitterEngine still refuses to post any of the requests until after I've performed all 3 sendUpdates request.

Does anyone know how I can work around this issue, by forcing it to send the first update, have it wait until it receives a response confirming or rejecting the tweet and then making the second tweet request, and so on?


I found a solution.

I modified the engine to have a new member:

NSMutableArray *messages;

And a new method that sends tweets from the array. When we recieve a response from the server, we check the array to see if there are any messages left and, if so, send another message from the array. Repeat until the array is empty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜