Giter VIP home page Giter VIP logo

twittersearchkit's Introduction

TwitterSearchKit

Demo SDK for fetching Tweets with the Twitter API

Requirements

  • iOS 9.0+
  • Swift 3.1 or Objective-C

Installation

CocoaPods

To use the SDK with CocoaPods add the following lines to your podfile's target:

use_frameworks!

pod 'TwitterSearchKit', :git => 'https://github.com/juxs/TwitterSearchKit.git'

Manual

Download the project and drag the TwitterSearchKit.xcodeproj file into your XCode's project navigator.

Usage

Objective-C Support

Objective C classes are using the TS prefix. For instance, TwitterSearchKit becomes TSTwitterSearchKit.

Add @import TwitterSearchKit; to the Objective C file.

Usage

First the Twitter API credentials have to be set in the AppDelegate. It must be a Base64 encoded string containing the format consumerKey:consumerSecret (as described here). ConsumerKey and ConsumerSecret can be obtained on https://dev.twitter.com and are used for application-only API requests

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
        
        //Set Twitter credentials
        TwitterSearchKit.tokenCredentials = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        
        return true
}

This is the implementation for fetching tweets with a given search term (the string of a hashtag):

TwitterSearchKit.getTweets(withSearchTerm: "AnyHashtagString") { (tweets) in
        //parse tweets
}

Tweets are asynchronously fetched and returned as an optional array of Dictionaries. Each dictionary contains the raw Twitter API response. The request failed if the array is nil. If that's the case make sure your API credentials are set correctly.

Samples

There are sample apps in this repository.

Swift Sample

Objective-C Sample

To run check out this repo and open the Library project file as the samples are targets.

twittersearchkit's People

Contributors

juxs avatar

Stargazers

 avatar

Watchers

 avatar

twittersearchkit's Issues

How you are combining the two strings ??

It must be a Base64 encoded string containing the format consumerKey:ConsumerSecret.

you convert them in which format ?
base64_consumerKey + ":" + base64_ConsumerSecret
or
consumerKey + ":" + ConsumerSecret
then to base64

??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.