Swiftpack.co - simorgh3196/Twifter as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by simorgh3196.
simorgh3196/Twifter 0.2.0
Twitter API Client written in Swift
⭐️ 9
🕓 2 years ago
iOS
.package(url: "https://github.com/simorgh3196/Twifter.git", from: "0.2.0")

Twifter

SwiftVersion License Platform Build Status codecov

:exclamation: This is a beta version!

Task

  • ☐ Twitter OAuth Authentication
    • ☑ OAuth
    • ☐ iOS internal twitter account
    • ☐ App Only Authentication
  • ☐ Twitter REST APIs
  • ☐ Installation
    • ☑ Cocoapods
    • ☐ Carthage
    • ☑ Swift Package Manager
  • ☐ Document
  • ☐ Platform
    • ☑ iOS
    • ☐ Mac
    • ☐ Linux
    • ☐ tvOS
    • ☐ watchOS

Requirements

iOS 11.0+

Installation

Cocoapods

pod 'Twifter'

Carthage

github 'simorgh3196/Twifter'

Swift Package Manager

.package(url: "https://github.com/simorgh3196/Twifter.git", .upToNextMajor(from: "0.2.0")),

Setup

  • Set URL Types in Info.plist
  • Set ConsumerToken, Secret and OAuth callback handler in AppDeleagte.swift
import UIKit
import Twifter

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Set consumerToken and consumerSecret
        Twifter.registerConsumerKey(token: "*************************",
                                    secret: "**************************************************")
        return true
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        // Set handler of twitter oauth callback
        Twifter.handleOpenURL(url: url)

        return true
    }

}

Usage

OAuth Authentication

callbackURL is defined by URL Types in Info.plist

let callbackURL = URL(string: "twifter://")!
Twifter.authentication(viewController: self, callbackURL: callbackURL, handler: { result in
    switch result {
    case .success(let accessToken):
        print("success!!!")
        print("AccessToken is " + accessToken)

    case .failure(let error):
        print(error)
    }
})

Get Tweets

let twifter = Twifter(accessToken: accessToken)
twifter.getTimeline { tweets in
  print(tweets)
}

Document

TODO

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/simorgh3196/Twifter.

License

The module is available as open source under the terms of the MIT License.

GitHub

link
Stars: 9
Last commit: 15 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics