1

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 out 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?

lionfly
  • 479
  • 7
  • 21

1 Answers1

0

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];
}
joshpaul
  • 953
  • 8
  • 12
  • Hi josh thanks, but the code does not get & in the tweet as well. How should I use URL shortener in the code? – lionfly Nov 09 '10 at 10:36
  • You should be able to call out to any of the url shorteners with the url you need to post to twitter, get back a "clean" url, and then post that. See this SO thread for implementation details: http://stackoverflow.com/questions/2252470/implementing-url-shorteners-in-my-iphone-application – joshpaul Nov 10 '10 at 18:06