iphone - 如何在 IOS 中嵌入 Twitter 提要和/或主题标签
<p><p>我基本上只需要一个表格 View ,它显示来自 tableviewcontroller 中 @username 或 #hashtag 的最新推文。没有发布推文或类似内容的要求。</p>
<p>目前我使用 <code>MGTwitterEngine</code>,它很复杂,只获取与用户名相关的推文而不是 hastags。</p>
<p>我找到了 <a href="http://www.forcegrind.com/2011/07/26/ios-how-to-embed-a-twitter-feed-andor-hashtag-in-your-app/" rel="noreferrer noopener nofollow">tutorial</a>但大部分代码没有解释,也没有源代码。</p>
<p>也可以找到 <a href="http://www.codeproject.com/Articles/312325/Making-a-simple-Twitter-app-using-iOS-5-Xcode-4-2?msg=4444279#xx4444279xx" rel="noreferrer noopener nofollow">this</a>但似乎 <code>http://search.twitter.com/search?q=%23</code>+ #hashtag 返回 <code>nil</code> 数据</p>
<p>也看到了 <a href="https://stackoverflow.com/questions/4860699/twitter-integration-in-iphone-to-read-public-tweets-hashtags-without-using-logi" rel="noreferrer noopener nofollow">question</a>为 ARC 编辑代码并使用 <code>http://search.twitter.com/search.json?q=%23epicwinning+OR+%40charliesheen</code> 链接获取数据</p>
<pre><code>#import <Foundation/Foundation.h>
@protocol latestTweetsDelegate
- (void)returnedArray:(NSArray*)tArray;
@end
@interface latestTweets : NSObject
{
NSMutableData *responseData;
NSMutableArray *resultsArray;
id<latestTweetsDelegate> delegate;
}
@property (nonatomic, strong) NSMutableArray *resultsArray;
@property (strong,nonatomic) id<latestTweetsDelegate> delegate;
- (id)initWithTwitterURL:(NSString *)twitterURL;
@end
#import "latestTweets.h"
#import "SBJson.h"
@implementation latestTweets
@synthesize resultsArray, delegate;
- (id)initWithTwitterURL:(NSString *)twitterURL
{
self = ;
if (self) {
responseData = ;
NSURLRequest *request = ];
[ initWithRequest:request delegate:self];
}
return self;
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
;
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
NSLog(@"Connection failed: %@", );
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString = [ initWithData:responseData encoding:NSUTF8StringEncoding];
NSArray *newData = ;
;
}
@end
</code></pre>
<p>我打电话</p>
<pre><code>latestTweets *lt = [ initWithTwitterURL:@"http://search.twitter.com/search.json?q=%23epicwinning+OR+%40charliesheen"];
lt.delegate = self;
</code></pre>
<p>返回结果数组:<code>-: unrecognized selector sent to instance</code> </p>
<p>是否有任何简单的教程或代码示例可以同时获取用户名和主题标签推文? </p>
<p>或</p>
<p>有没有办法使用 <code>MGTwitterEngine</code> 来获取主题标签? </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>看看<a href="https://github.com/nst/STTwitter" rel="noreferrer noopener nofollow">STTwitter</a> .</p>
<pre><code>STTwitterAPI *twitter =
[STTwitterAPI twitterAPIApplicationOnlyWithConsumerKey:@""
consumerSecret:@""];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *bearerToken) {
[twitter getSearchTweetsWithQuery:@"Snowden"
successBlock:^(NSDictionary *searchMetadata, NSArray *statuses) {
// use the statuses here
} errorBlock:^(NSError *error) {
// ...
}];
} errorBlock:^(NSError *error) {
// ...
}];
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 如何在 IOS 中嵌入 Twitter 提要和/或主题标签,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/14242391/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/14242391/
</a>
</p>
页:
[1]