Swiftpack.co - simorgh3196/Twifter as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
simorgh3196/Twifter
Twitter API Client written in Swift
.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: 7
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Dependencies

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