Latest 1.0.0
Homepage https://github.com/pisces/TwitterSDK
License MIT
Platforms ios 7.0, requires ARC
Dependencies OAuthConsumer
Frameworks Foundation, UIKit
Authors

CI Status
Version
License
Platform

Demo App Screen Shot

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Set up

AppDelegate

#import "DemoAppDelegate.h"
#import <TwitterSDK/TwitterSDK.h>

NSString *const twitterConsumerkey = @"Your Consumer Key for Twitter API";
NSString *const twitterConsumerSecret = @"Your Consumer Secret for Twitter API";
NSString *const twitterOAuthCallbackURL = @"http://yourSiteDomain/oauth_callback";
NSString *const twitterRedirectURLString = @"yourAppScheme://authorize_complete";
NSString *const twitterServiceProviderName = @"yourServiceProviderName"; //ex twitterSDKDemoApp
NSString *const twitterPrefix = @"yourSiteDomain"; //ex twittersdkdemoapp.com

@implementation DemoAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[TwitterAppCenter defaultCenter] setUpWithKey:twitterConsumerkey
                                            secret:twitterConsumerSecret
                                 callbackURLString:twitterOAuthCallbackURL
                                  rediectURLString:twitterRedirectURLString
                               serviceProviderName:twitterServiceProviderName
                                            prefix:twitterPrefix];
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if ([[TwitterAppCenter defaultCenter] matchedURL:url])
        return [[TwitterAppCenter defaultCenter] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];

    return YES;
}

@end

Info.plist

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLIconFile</key>
        <string></string>
        <key>CFBundleURLName</key>
        <string>mytwitter</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>twitterSDKDemoApp</string>
        </array>
    </dict>
</array>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>twimg.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
        </dict>
        <key>twitter.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>twittersdkdemoapp.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
        </dict>
    </dict>
</dict>

Example

@implementation DemoViewController
{
    __weak IBOutlet UITextView *textView;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"TwitterSDK Demo";
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    if ([TwitterAppCenter defaultCenter].hasSession) {
        [self load];
    } else {
        [[TwitterAppCenter defaultCenter] loginWithCompletion:^(id result, NSError *error) {
            if (!error) {
                [self load];
            }
        }];
    }
}

- (void)load {
    NSString *path = @"https://api.twitter.com/1.1/statuses/home_timeline.json";
    NSDictionary *params = @{@"count": @"10",
                             @"user_id": [TwitterAppCenter defaultCenter].oauth.user.user_id,
                             @"screen_name": [TwitterAppCenter defaultCenter].oauth.user.screen_name};

    [[TwitterAppCenter defaultCenter] apiCallWithPath:path params:params completion:^(NSDictionary *result, NSError *error) {
        NSLog(@"result -> %@", result);
        textView.text = [NSString stringWithFormat:@"%@", result];
    }];
}

@end

Requirements

iOS Deployment Target 7.0 higher

Installation

TwitterSDK is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "TwitterSDK"

Author

pisces, [email protected]

License

TwitterSDK is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "TwitterSDK",
    "version": "1.0.0",
    "summary": "TwitterSDK.",
    "description": "TwitterSDK is open source to use apis of twitter.",
    "homepage": "https://github.com/pisces/TwitterSDK",
    "license": "MIT",
    "authors": {
        "pisces": "[email protected]"
    },
    "source": {
        "git": "https://github.com/pisces/TwitterSDK.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "TwitterSDK/Classes/**/*",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "dependencies": {
        "OAuthConsumer": []
    },
    "resource_bundles": {
        "TwitterSDK": [
            "TwitterSDK/Assets/*"
        ]
    },
    "pod_target_xcconfig": {}
}

Pin It on Pinterest

Share This