ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - mattdonnelly/Swifter: [DEPRECATED] A Twitter framework for iOS & OS X written in Swift
[DEPRECATED] :bird: A Twitter framework for iOS & OS X written in Swift - GitHub - mattdonnelly/Swifter: [DEPRECATED] A Twitter framework for iOS & OS X written in Swift
Visit Site

GitHub - mattdonnelly/Swifter: [DEPRECATED] A Twitter framework for iOS & OS X written in Swift

GitHub - mattdonnelly/Swifter: [DEPRECATED] A Twitter framework for iOS & OS X written in Swift

⚠️ This project has been deprecated: https://github.com/mattdonnelly/Swifter/issues/360 ⚠️


Carthage compatible

Getting Started

Installation

If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own project and adding either the SwifteriOS or SwifterMac framework as an embedded framework.

Usage

Swifter can be used with the 3 different kinds of authentication protocols Twitter allows. You can specify which protocol to use as shown below. For more information on each of the authentication protocols, please check Twitter OAuth Help.

Instantiation with ACAccount:


// Instantiation using ACAccount
var swifter = Swifter(account: twitterAccount)

// Instantiation using Twitter's OAuth Consumer Key and secret
swifter = Swifter(consumerKey: TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_SECRET)

// Instantiation using App-Only authentication
swifter = Swifter(consumerKey: TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_SECRET, appOnly: true)

Example Requests

OAuth Authorization:

swifter.authorize(with: callbackURL, success: { accessToken, response in
  // ...
}, failure: { error in
  // ...
})

Get Home Timeline:

swifter.getHomeTimeline(count: 50, success: { json in
  // ...
}, failure: { error in
  // ...
})

ListTag, UserTag, and UsersTag

Certain Twitter API calls allows you to use either the user_id or screen_name to get user related objects (and list_id/slug for lists). Swifter offers a solution so that the user won't accidentally use the wrong method, and have nothing returned. For more information, check the SwifterTag.swift file.

swifter.getUserFollowersIDs(for: .id(userId), success: { json, prev, next in
    // alternatively, you can use .screenName(userName)
    // ...
}, failure: { error in
    // ...
})


swifter.getListSubscribers(for: .slug(listSlug, owner: .screenName(userName)), success: { json, prev, next in
    // alternatively, you can use .id(listId)
    // ...
}, failure: { error in
    // ...
})

Additionally, there is also .screenName(arrayOfUserNames) and .id(arrayOfIds) for methods that take arrays of screen names, or userIDs

Streaming API:

Important Note: Twitter has deprecated the Streaming API in favour of their new Accounts Activity API. You can find out more about migrating to the new API here. Twitter plans to remove the old streaming API on August 16, 2018, Swifter will remove the endpoints for it shortly after that.

swifter.streamRandomSampleTweets(progress: { status in
  // ...
}, stallWarnings: { code, message, percentFull in
  // ...
}, failure: { error in
  // ...
})

Status Update:

swifter.postTweet(status: "Hello, world.", success: { status in
  // ...
}, failure: { error in
  // ...
})

JSON Handling

To make accessing data returned by twitter requests simple, Swifter provides a class for representing JSON which you interact with similarly to a dictionary. The main advantage of using this instead of a Dictionary<String, AnyObject> is that it works better with Swift's strict typing system and doesn't require you to constantly downcast accessed objects. It also removes the need for lots of optional chaining, making your code much cleaner and easier to read.

Here's an example of how you would access the text of the first element in list of statuses:

if let statusText = statuses[0]["text"].string {
    // ...
}

OAuth Consumer Tokens

In Twitter REST API v1.1, each client application must authenticate itself with consumer key and consumer secret tokens. You can request consumer tokens for your app on Twitter's dev website

Single Sign-On [Deprecated]

If you authorize with SSO, you should add URL-Scheme your Info.plist. REPLACE $(TWITTER_CONSUMER_KEY) TO YOUR CONSUMER KEY.

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>swifter-$(TWITTER_CONSUMER_KEY)</string>
		</array>
	</dict>
</array>

License

Swifter is licensed under the MIT License. See the LICENSE file for more information.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory