【发布时间】:2014-11-05 21:18:45
【问题描述】:
我已经能够在 iOS 上发布数百次推文,但我遇到了一条我无法发推的推文。这条推文只有 130 个字符,但 Twitter 回应称它超过 140 个字符。所以 Twitter 不会发布它。
相关代码:
- (void)tweet:(NSString *)message
{
SLRequest* request = [SLRequest
requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString:[NSString stringWithFormat:
@"%@statuses/update.json",
API_BASE_URL
]]
parameters:@{
@"status": message
}
];
request.account = self.context.account;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *eror) {
if (responseData != nil) {
NSLog(@"%@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
}
];
}
控制台打印输出:
(lldb) po message
@juandoming Dallas teachers improved student performance by 20% w/mobile video messaging. Would this be useful to you? Ccccccc.com
(lldb) p message.length
(unsigned int) $1 = 130
2014-09-11 12:25:01.326 app[1685:6b13] {"errors":[{"code":186,"message":"Status is over 140 characters."}]}
(lldb)
实际网址不是Ccccccc.com,但字符数相同。
【问题讨论】:
-
我猜它与 URL 有关,也许他们正在尝试 t.co-ify 链接或其他什么?尝试用相同数量的文本替换 URL,看看问题是否仍然存在..
-
没有办法取回转换后的消息吗?似乎有些东西正在修改原始内容,例如添加
http://等 -
我不相信 URL 正在被转换。发布成功后,我的 URL 将保持不变。
-
更正:URL 出现没有改变,但是当我将鼠标悬停在它上面时,我看到它已转换为 22 个字符的 t.co/XXX url。
标签: ios objective-c cocoa-touch twitter