MGTwitterEngine - 最喜欢的推文
我正在尝试使用 MGTwitterEngine 收藏一条推文,
我正在使用“Tweet”,这是我制作的一个子类,用于处理用户 ID、名称等。因此,我将其放入一个字符串中,然后将其转换为可用于处理最喜欢的行为。推文
I am attempting to favorite a tweet using MGTwitterEngine
I am using "Tweet" a sub-class I made which handles the user ids, names, etc. So I put that into a string which then gets converted to a number that can be used to handle the act of fav. a tweet
My Code: http://pastie.org/1467311
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一篇非常古老的帖子,不确定是否有人在寻找它,但在经历了一些“偶然”之后,我今天成功地做到了这一点。您需要执行以下操作:
至少实现以下方法来获取状态
statuses 数组的第一个位置有一个 NSDictionary。提取如下
从字典“source_api_request_type”和“id”中提取两个键。将它们都保存为 NSString 值。
更新 MGTwitterEngine.h 和 MGTwitterEngine.m 以更改 markUpdate 方法的方法签名,将 updateID 作为 NSString 而不是 unsigned int 发送。更改后它将类似于以下内容:
将 markUpdate 方法中的
%u
更改为%@
,以便正确应用输入参数更改。 (您必须在方法中的两个地方进行更改)回到代码中,您将使用类似于以下内容的内容来发送推文。
一旦推文成功发布,这将引发 statusRecieved 事件。在前面提到的 statusRecieved 事件中,我们需要两个值:tweetId 和请求类型。
使用以下代码检查 request Type == 5 是否存在,如果是,则通过传递 tweet Id 值和布尔值 YES 来收藏该推文(或 NO 来取消收藏)来调用 markUpdate 方法。您的代码将如下所示:
“请求类型”5 的秘密在于,新推文发布的“api 请求 id”为 5,并且我们希望将新推文仅标记为最喜欢的。 (当您在推文被标记为收藏后查看 id 时,它的状态将是 26)。
随着 iOS 5 的临近,MGTwitterEngine 将很快被弃用。但在我自己的项目中解决这个问题对我来说很有趣。希望有人觉得它有用。
This is a very old post and not sure if anyone is looking out for it, but I managed to do this exact thing today after some 'hit-and-miss'. Here is what you have to do:
Implement atleast the following method to get status
The statuses array has a NSDictionary at the first position. Extract it as follows
Extract two keys from the Dictionary "source_api_request_type" and "id". Save both of them as NSString values.
Update the MGTwitterEngine.h and MGTwitterEngine.m to change method signature of the markUpdate method to send the updateID as a NSString instead of unsigned int. It will look similar to the following after change:
Change the
%u
in markUpdate method to%@
so that the input parameter change applies correctly. (You have to make the change at two places in the method)Back in your code you will use something similar to the following to send the tweet.
This will raise the statusRecieved event once the tweet is posted successfully. In statusRecieved event as mentioned earlier we need two values the tweetId and the request type.
Use the following code to check if request Type == 5, and if it is call the markUpdate method by passing the values the tweet Id and boolean value of YES to favorite (or NO to un-favorite) the tweet. Your code will look like this:
The secret sauce of 'request type' 5 is that a new tweet posting has 'api request id' of 5 and we want want to mark new tweets as favorite only. (When you watch the id after the tweet is marked favorite it will be status 26).
With iOS 5 looming MGTwitterEngine will soon be deprecated. But it was fun for me to figure this out in my own project. Hope someone finds it useful.