Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, you need to <code>Authenticate</code> your request (Get permission).</p> <p>second, see follow <strong>these steps</strong>:</p> <p>1.Download <a href="https://github.com/fhsjaagshs/FHSTwitterEngine" rel="noreferrer">FHSTwitterEngine</a> Twitter Library.</p> <p>2.Add the folder <code>FHSTwitterEngine</code>" to your project and <code>#import "FHSTwitterEngine.h"</code>.</p> <p>3.add <code>SystemConfiguration.framework</code> to your project.</p> <blockquote> <p>Usage : 1.in the <code>[ViewDidLoad]</code> add the following code.</p> </blockquote> <pre><code>UIButton *logIn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; logIn.frame = CGRectMake(100, 100, 100, 100); [logIn setTitle:@"Login" forState:UIControlStateNormal]; [logIn addTarget:self action:@selector(showLoginWindow:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:logIn]; [[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"&lt;consumer_key&gt;" andSecret:@"&lt;consumer_secret&gt;"]; [[FHSTwitterEngine sharedEngine]setDelegate:self]; </code></pre> <p>and <strong>don't forget</strong> to import the delegate <code>FHSTwitterEngineAccessTokenDelegate</code>.</p> <blockquote> <ol start="2"> <li>you need to get the permission for your request, with the following method which will present Login window:</li> </ol> </blockquote> <pre><code>- (void)showLoginWindow:(id)sender { [[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) { NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!"); }]; } </code></pre> <p>when the Login window is presented, enter your Twitter <code>Username</code> and <code>Password</code> to <code>authenticate</code> your request.</p> <blockquote> <ol start="3"> <li>add the following methods to your code:</li> </ol> </blockquote> <pre><code>-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[FHSTwitterEngine sharedEngine]loadAccessToken]; NSString *username = [[FHSTwitterEngine sharedEngine]loggedInUsername];// self.engine.loggedInUsername; if (username.length &gt; 0) { lbl.text = [NSString stringWithFormat:@"Logged in as %@",username]; [self listResults]; } else { lbl.text = @"You are not logged in."; } } - (void)storeAccessToken:(NSString *)accessToken { [[NSUserDefaults standardUserDefaults]setObject:accessToken forKey:@"SavedAccessHTTPBody"]; } - (NSString *)loadAccessToken { return [[NSUserDefaults standardUserDefaults]objectForKey:@"SavedAccessHTTPBody"]; } </code></pre> <blockquote> <p>4.Now you are ready to get your request, with the following method(in this method I created a <code>Twitter</code> search for some <code>Hashtag</code>, to get the <code>screen_name</code> for example):</p> </blockquote> <pre><code>- (void)listResults { dispatch_async(GCDBackgroundThread, ^{ @autoreleasepool { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; // the following line contains a FHSTwitterEngine method wich do the search. dict = [[FHSTwitterEngine sharedEngine]searchTweetsWithQuery:@"#iOS" count:100 resultType:FHSTwitterEngineResultTypeRecent unil:nil sinceID:nil maxID:nil]; // NSLog(@"%@",dict); NSArray *results = [dict objectForKey:@"statuses"]; // NSLog(@"array text = %@",results); for (NSDictionary *item in results) { NSLog(@"text == %@",[item objectForKey:@"text"]); NSLog(@"name == %@",[[item objectForKey:@"user"]objectForKey:@"name"]); NSLog(@"screen name == %@",[[item objectForKey:@"user"]objectForKey:@"screen_name"]); NSLog(@"pic == %@",[[item objectForKey:@"user"]objectForKey:@"profile_image_url_https"]); } dispatch_sync(GCDMainThread, ^{ @autoreleasepool { UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Complete!" message:@"Your list of followers has been fetched" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [av show]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; } }); } }); } </code></pre> <p>That's all. I just got the screen_name from a search Query, you can get a timeline for a user using the following methods:</p> <pre><code>// statuses/user_timeline - (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count; - (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID; </code></pre> <p>instead of the search method above.</p> <p>Note: see the <code>FHSTwitterEngine.h</code> to know what method you need to use. Note: to get the <code>&lt;consumer_key&gt;</code> and the <code>&lt;consumer_secret&gt;</code> you need to to visit this <a href="https://dev.twitter.com/apps" rel="noreferrer">link</a> to register your app in Twitter. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload