Jayr Parro

Incorrect Signature - ShareKit+Twitter Error

I’m using ShareKit v0.2.1 in our app to integrate FB and Twitter status updates. The FB service is working fine. However, in the Twitter service I encountered this error:

1
2
3
4
Twitter Send Status Error:{
  "request":"\/1\/statuses\/update.json",
    "error":"Incorrect signature"
}

I’m just concerned of sharing the URL to be posted in the user’s wall.
Reported the problem/bug here.

I found out that the Twitter oAuth has been updated and breaks in this latest release of ShareKit.

Excerpts from Twitter oAuth docs (https://dev.twitter.com/doc/get/oauth/authorize):

Please use HTTPS for this method, and all other OAuth token negotiation steps.

To fix this issue, we need to change SHKTwitter.m in lines 54-56
from https://twitter.com/ to https://api.twitter.com/

1
2
3
self.authorizeURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/authorize"];
self.requestURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];
self.accessURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];

Then, in sendStatus method update the URL link:

1
OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://api.twitter.com/1/statuses/update.json"] consumer:consumer token:accessToken realm:nil signatureProvider:nil];

This should be fix in the next version of ShareKit. :)

Strip HTML Tag in NSString

This is a handy method to strip the HTML Tags in NSString object.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
+(NSString *)flattenHTML:(NSString *)html
{
  NSScanner *thescanner;
  NSString *text = nil;
  thescanner = [NSScanner scannerWithString:html];
  
  while ([thescanner isAtEnd] == NO) {
      //find start of tag
      [thescanner scanUpToString:@"<" intoString:nil];

      //find end of tag
      [thescanner scanUpToString:@">" intoString:&text];

      //replace the found tag with a space
       //(you can filter multi-spaces out later if you wish)
      html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""];
  }

   // Trimmed return
   return [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}

Thanks to the original poster.
I’ve just change the return string to trim whitespaces.

Cheers!

iPhone Memory Debugging Using Instruments and NSZombie Enabled

When your iPhone app crashes caused by “BAD ACCESS”, it’s really painful to trace the code fault. It feels good Instruments have support for enabling the NSZombie detection.

Thanks to markj for writing this good guide…definitely, helped me out.

Cheers!