开发者

What code should I use to get & (not &) in the tweet?

I use Twitter-OAuth-iPhone to POST tweets by [_engine sendUpdate:myText];, which works fine. However, the letter & in the 'myText' will be changed to & in the tweet shown on Twitter.com. The & is for coordinates link: @"http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q=%f,+%f".

I tried to replace the & with %%26 in the 'myText', which turns ou开发者_StackOverflowt with %26 in the tweet instead of &; and when I replace with %26, the app crash.

What code should I use to get & (not &) in the tweet?


You may need to use a URL shortener, since Twitter may be doing something to avoid SQL injection and the like.

Otherwise, does this work for you?

- (NSString *)stringByReplacingPercentEscapesFromString:(NSString *)inString
{
    NSString *outString = (NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)inString, CFSTR(""));
    return [outString autorelease];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜