2011年5月23日 星期一

How to post message to Twitter from iPhone App

Step 1: Create a new application of Twitter from app registration and you will see the information as below.
It contains two key values we will need.

Consumer key

uc5Ag3Oog5Ot3lWtt4w91Q

Consumer secret

ZFcLlWfQEq5poFDpFuTRHAVdHWPVctQYu6wXM2qpTQ
Step 2: Download Twitter SDK
Step 3: Add Twitter SDK into your project.
Step 4: Add libxml2.dylib into Framework
Step 5: Add $(SDKROOT)/usr/include/libxml2 in "Header Search Paths"
Step 6: Replace key values with previous what we got in TwitterControl.m
#define kOAuthConsumerKey @"uc5Ag3Oog5Ot3lWtt4w91Q"
#define kOAuthConsumerSecret @"ZFcLlWfQEq5poFDpFuTRHAVdHWPVctQYu6wXM2qpTQ"

Step 7: Integrate Twitter SDK with your project
  • Add #import "TwitterControl.h" and TwitterControlProtocol in xxxx.h
  • Implement TwitterControlProtocol
-(void)didPostComplete:(TwitterControl *)control success:(BOOL)result
{
    [control autorelease];
}
  • Post message to twitter
[TwitterControl postMessage:self msg:@"your message"];


Reference from here

沒有留言:

張貼留言