SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Twitter APIs
Andy Piper
Developer Advocate
@andypiper
Twitter APIs deal both with 

the moment and the past
The Moment: Streaming API
t.co/streaming
1% sample, or track keywords
The Past: REST API

t.co/rest
Optimize your calls
4
Create your app: easy

t.co/apps



Don’t re-invent the wheel: libs
t.co/libs
@andypiper
Help?
Join the conversation in the
Twitter Community forums
Follow @TwitterAPI, @AdsAPI and
@TwitterDev for platform updates
Developer Resources
Documentation
dev.twitter.com
Streaming API
t.co/streaming
REST API
t.co/rest
Create App
t.co/apps

Open Source Libs
t.co/libs
Code Examples
t.co/code
Crashlytics Answers Twitter Digits MoPub
A D S A P I
t.co/adsapi
G E T T I N G S TA R T E D
</>
PRE-REQUISITES
SETUP
RUBY VERSION
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
$ gem install pry jsonpretty twurl
INSTALLING TOOLS & DEPENDENCIES
Note: Depending on how your Ruby installation is setup, you may need
to run the above “gem install” commands with “sudo”.
AUTHORIZATION
More info at: https://dev.twitter.com/oauth
OAUTH 1.0A
The Ads API uses OAuth 1.0a for
authorization and implements the
3-legged OAuth flow.
AUTHORIZATION
API key and secret are available under the “Keys and Access Tokens” tab.
CONSUMER KEY & SECRET
Your consumer key is a
publicly visible identifier for
your app.
You should never share your
consumer secret.
</>
PRE-REQUISITES
SETUP
AUTHORIZATION
$ twurl authorize --consumer-key key --consumer-secret secret
VALIDATE SETUP
$ cat ~/.twurlrc
TRY IT OUT
$ twurl -H ads-api-sandbox.twitter.com "/1/accounts" | jsonpretty
PER MINS / ENDPOINT
25
REQUESTS
READS
PER MIN / CATEGORY
100
REQUESTS
WRITES
D E V E LO P E R R AT E L I M I TS
More info at: https://dev.twitter.com/ads/basics/rate-limiting
W O R K S H O P
</>
INSTALLING THE RUBY SDK
$ gem install twitter-ads
RUBY SDK
SETUP
$ twitter-ads
twitter-ads v0.3.4 >>
START AN INTERACTIVE SESSION
Note: Depending on how your Ruby installation is setup, you may need
to run the above “gem install” commands with “sudo”.
</>
RUBY SDK
CLIENT
# enable sandbox mode
CLIENT.options[:sandbox] = true
# load up the account instance
account = CLIENT.accounts.first
# enable request tracing (optional,
= true
good for troubleshooting)
CLIENT.options[:trace]
http://bit.ly/ads-api-client
</>http://bit.ly/ads-api-campaign
RUBY SDK
CAMPAIGN
# create
campaign = TwitterAds::Campaign.new(account)
your campaign
campaign.funding_instrument_id = account.funding_instruments.first.id
campaign.daily_budget_amount_local_micro = 1_000_000
campaign.name = 'my first campaign'
campaign.paused = true
campaign.start_time = Time.now.utc
campaign.save
</>http://bit.ly/ads-api-line-item
RUBY SDK
LINE ITEM
# create a line item for the campaign
line_item = TwitterAds::LineItem.new(account)
line_item.name = 'my first ad'
line_item.product_type = TwitterAds::Product::PROMOTED_TWEETS
line_item.placements = [TwitterAds::Placement::ALL_ON_TWITTER]
line_item.objective = TwitterAds::Objective::TWEET_ENGAGEMENTS
line_item.bid_amount_local_micro = 10_000
line_item.paused = true
line_item.save
line_item.campaign_id = campaign.id
TWEET RETWEET PROMOTED TWEET
</>http://bit.ly/ads-api-promoted-tweet
RUBY SDK
PROMOTED TWEET
# create
resource
request for a simple null-casted tweet
= "/1/accounts/#{account.id}/tweet"
tweet_params = { status: ‘Hello @AdsAPI!’ }
request = TwitterAds::Request.new(CLIENT, :post, resource, params: tweet_params)
tweet = request.perform
# promote the tweet using our line item
promoted_tweet = TwitterAds::Creative::PromotedTweet.new(account)
promoted_tweet.line_item_id = line_item.id
promoted_tweet.tweet_id = tweet.body[:data][:id]
promoted_tweet.save
</>http://bit.ly/ads-api-targeting
RUBY SDK
TARGETING
# fetching targeting criteria values
resource = '/1/targeting_criteria/locations'
params = { location_type: 'COUNTRY', q: 'u' }
request = TwitterAds::Request.new(CLIENT, :get, resource, params: params)
cursor = TwitterAds::Cursor.new(nil, request)
# add targeting criteria
targeting_criteria = TwitterAds::TargetingCriteria.new(account)
targeting_criteria.line_item_id = line_item.id
targeting_criteria.targeting_type = 'LOCATION'
targeting_criteria.targeting_value = '00a8b25e420adc94'
targeting_criteria.save
</>http://bit.ly/ads-api-analytics
RUBY SDK
ANALYTICS
# limit request count and grab the first 10 line items from TwitterAds::Cursor
line_items = account.line_items(nil, count: 10)[0..9]
# the list of metrics we want to fetch
metrics = [:billed_engagements, :billed_follows]
# fetching stats on the instance
line_items.first.stats(metrics)
# fetching stats for multiple line items
ids = line_items.map { |line_item| line_item.id }
TwitterAds::LineItem.stats(account, ids, metrics)
#THANKYOU

Más contenido relacionado

La actualidad más candente

How to hack a node app? @ GDG DevFest Ukraine 2017
How to hack a node app? @  GDG DevFest Ukraine 2017How to hack a node app? @  GDG DevFest Ukraine 2017
How to hack a node app? @ GDG DevFest Ukraine 2017Asim Hussain
 
Apps for Science - Elsevier Developer Network Workshop 201102
Apps for Science - Elsevier Developer Network Workshop 201102Apps for Science - Elsevier Developer Network Workshop 201102
Apps for Science - Elsevier Developer Network Workshop 201102remko caprio
 
Really Awesome WordPress Plugins You Should Know About
Really Awesome WordPress Plugins You Should Know AboutReally Awesome WordPress Plugins You Should Know About
Really Awesome WordPress Plugins You Should Know AboutAngela Bowman
 
Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Raffi Krikorian
 
Introduction to WordPress Security
Introduction to WordPress SecurityIntroduction to WordPress Security
Introduction to WordPress SecurityShawn Hooper
 
Intro to developing for @twitterapi
Intro to developing for @twitterapiIntro to developing for @twitterapi
Intro to developing for @twitterapiRaffi Krikorian
 
WordPress Security Presentation
WordPress Security PresentationWordPress Security Presentation
WordPress Security PresentationAndrew Paton
 
Hunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forestHunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forestSecuRing
 
All your family secrets belong to us—Worrisome security issues in tracker apps
All your family secrets belong to us—Worrisome security issues in tracker appsAll your family secrets belong to us—Worrisome security issues in tracker apps
All your family secrets belong to us—Worrisome security issues in tracker appsPriyanka Aash
 
Attacking open source using abandoned resources
Attacking open source using abandoned resourcesAttacking open source using abandoned resources
Attacking open source using abandoned resourcesAdam Baldwin
 
Approaching the unknown - Windows Phone application security assessment guide
Approaching the unknown - Windows Phone application security assessment guideApproaching the unknown - Windows Phone application security assessment guide
Approaching the unknown - Windows Phone application security assessment guideSecuRing
 
Mobile Performance Testing Crash Course
Mobile Performance Testing Crash CourseMobile Performance Testing Crash Course
Mobile Performance Testing Crash CourseTechWell
 
What should I do when my website got hack?
What should I do when my website got hack?What should I do when my website got hack?
What should I do when my website got hack?Sumedt Jitpukdebodin
 
Testing iOS apps without jailbreak in 2018
Testing iOS apps without jailbreak in 2018Testing iOS apps without jailbreak in 2018
Testing iOS apps without jailbreak in 2018SecuRing
 
Poisoning Google images
Poisoning Google imagesPoisoning Google images
Poisoning Google imageslukash4
 
Workshop: building your mobile backend with Parse - Droidcon Paris2014
Workshop: building your mobile backend with Parse - Droidcon Paris2014Workshop: building your mobile backend with Parse - Droidcon Paris2014
Workshop: building your mobile backend with Parse - Droidcon Paris2014Paris Android User Group
 

La actualidad más candente (20)

How to hack a node app? @ GDG DevFest Ukraine 2017
How to hack a node app? @  GDG DevFest Ukraine 2017How to hack a node app? @  GDG DevFest Ukraine 2017
How to hack a node app? @ GDG DevFest Ukraine 2017
 
Apps for Science - Elsevier Developer Network Workshop 201102
Apps for Science - Elsevier Developer Network Workshop 201102Apps for Science - Elsevier Developer Network Workshop 201102
Apps for Science - Elsevier Developer Network Workshop 201102
 
Really Awesome WordPress Plugins You Should Know About
Really Awesome WordPress Plugins You Should Know AboutReally Awesome WordPress Plugins You Should Know About
Really Awesome WordPress Plugins You Should Know About
 
What's happening here?
What's happening here?What's happening here?
What's happening here?
 
Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)
 
Introduction to WordPress Security
Introduction to WordPress SecurityIntroduction to WordPress Security
Introduction to WordPress Security
 
Intro to developing for @twitterapi
Intro to developing for @twitterapiIntro to developing for @twitterapi
Intro to developing for @twitterapi
 
WordPress Security Presentation
WordPress Security PresentationWordPress Security Presentation
WordPress Security Presentation
 
API Design - 3rd Edition
API Design - 3rd EditionAPI Design - 3rd Edition
API Design - 3rd Edition
 
TL; DR: iOS 9R
TL; DR: iOS 9RTL; DR: iOS 9R
TL; DR: iOS 9R
 
Hunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forestHunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forest
 
All your family secrets belong to us—Worrisome security issues in tracker apps
All your family secrets belong to us—Worrisome security issues in tracker appsAll your family secrets belong to us—Worrisome security issues in tracker apps
All your family secrets belong to us—Worrisome security issues in tracker apps
 
Attacking open source using abandoned resources
Attacking open source using abandoned resourcesAttacking open source using abandoned resources
Attacking open source using abandoned resources
 
Invoke-DOSfuscation
Invoke-DOSfuscationInvoke-DOSfuscation
Invoke-DOSfuscation
 
Approaching the unknown - Windows Phone application security assessment guide
Approaching the unknown - Windows Phone application security assessment guideApproaching the unknown - Windows Phone application security assessment guide
Approaching the unknown - Windows Phone application security assessment guide
 
Mobile Performance Testing Crash Course
Mobile Performance Testing Crash CourseMobile Performance Testing Crash Course
Mobile Performance Testing Crash Course
 
What should I do when my website got hack?
What should I do when my website got hack?What should I do when my website got hack?
What should I do when my website got hack?
 
Testing iOS apps without jailbreak in 2018
Testing iOS apps without jailbreak in 2018Testing iOS apps without jailbreak in 2018
Testing iOS apps without jailbreak in 2018
 
Poisoning Google images
Poisoning Google imagesPoisoning Google images
Poisoning Google images
 
Workshop: building your mobile backend with Parse - Droidcon Paris2014
Workshop: building your mobile backend with Parse - Droidcon Paris2014Workshop: building your mobile backend with Parse - Droidcon Paris2014
Workshop: building your mobile backend with Parse - Droidcon Paris2014
 

Similar a Twitter APIs for #MediaHackday

API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
Creating a mule project with raml and api
Creating a mule project with raml and apiCreating a mule project with raml and api
Creating a mule project with raml and apiBhargav Ranjit
 
Deploy a web API in 15'
Deploy a web API in 15'Deploy a web API in 15'
Deploy a web API in 15'Restlet
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterSachin G Kulkarni
 
Build Android App using GCE & GAE
Build Android App using GCE & GAEBuild Android App using GCE & GAE
Build Android App using GCE & GAELove Sharma
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfKaty Slemon
 
I Love APIs - Oct 2015
I Love APIs - Oct 2015I Love APIs - Oct 2015
I Love APIs - Oct 2015Mike McNeil
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfKaty Slemon
 
Creating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services APICreating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services APIDavid Keener
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaPantheon
 
API Management Workshop (at Startupbootcamp Berlin)
API Management Workshop (at Startupbootcamp Berlin)API Management Workshop (at Startupbootcamp Berlin)
API Management Workshop (at Startupbootcamp Berlin)3scale
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngineikailan
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsMarcelo Pinheiro
 
Play Your API with MuleSoft API Notebook
Play Your API with MuleSoft API NotebookPlay Your API with MuleSoft API Notebook
Play Your API with MuleSoft API NotebookRakesh Kumar Jha
 

Similar a Twitter APIs for #MediaHackday (20)

API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
Creating a mule project with raml and api
Creating a mule project with raml and apiCreating a mule project with raml and api
Creating a mule project with raml and api
 
Deploy a web API in 15'
Deploy a web API in 15'Deploy a web API in 15'
Deploy a web API in 15'
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in Codeigniter
 
Build Android App using GCE & GAE
Build Android App using GCE & GAEBuild Android App using GCE & GAE
Build Android App using GCE & GAE
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
 
I Love APIs - Oct 2015
I Love APIs - Oct 2015I Love APIs - Oct 2015
I Love APIs - Oct 2015
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
 
Nativescript with angular 2
Nativescript with angular 2Nativescript with angular 2
Nativescript with angular 2
 
Creating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services APICreating a World-Class RESTful Web Services API
Creating a World-Class RESTful Web Services API
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon Vienna
 
API Management Workshop (at Startupbootcamp Berlin)
API Management Workshop (at Startupbootcamp Berlin)API Management Workshop (at Startupbootcamp Berlin)
API Management Workshop (at Startupbootcamp Berlin)
 
Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Play Your API with MuleSoft API Notebook
Play Your API with MuleSoft API NotebookPlay Your API with MuleSoft API Notebook
Play Your API with MuleSoft API Notebook
 
AIR & API
AIR & APIAIR & API
AIR & API
 

Más de Andy Piper

Adapt & Survive
Adapt & SurviveAdapt & Survive
Adapt & SurviveAndy Piper
 
Rebooting A Community #DevRelCon
Rebooting A Community #DevRelConRebooting A Community #DevRelCon
Rebooting A Community #DevRelConAndy Piper
 
Imagining the Future, when the Future is already Now
Imagining the Future, when the Future is already NowImagining the Future, when the Future is already Now
Imagining the Future, when the Future is already NowAndy Piper
 
Developer Advocacy - A Life Less Ordinary
Developer Advocacy - A Life Less OrdinaryDeveloper Advocacy - A Life Less Ordinary
Developer Advocacy - A Life Less OrdinaryAndy Piper
 
Twitter in the Internet of Things
Twitter in the Internet of ThingsTwitter in the Internet of Things
Twitter in the Internet of ThingsAndy Piper
 
Twitter APIs - the starter guide
Twitter APIs - the starter guideTwitter APIs - the starter guide
Twitter APIs - the starter guideAndy Piper
 
Connecting to the pulse of the planet with Twitter APIs
Connecting to the pulse of the planet with Twitter APIsConnecting to the pulse of the planet with Twitter APIs
Connecting to the pulse of the planet with Twitter APIsAndy Piper
 
Internet ALL the Things - a walking tour of MQTT
Internet ALL the Things - a walking tour of MQTTInternet ALL the Things - a walking tour of MQTT
Internet ALL the Things - a walking tour of MQTTAndy Piper
 
Combining Context with Signals in the IoT (longer version)
Combining Context with Signals in the IoT (longer version)Combining Context with Signals in the IoT (longer version)
Combining Context with Signals in the IoT (longer version)Andy Piper
 
Why the Internet of Things will be built on Open Source
Why the Internet of Things will be built on Open SourceWhy the Internet of Things will be built on Open Source
Why the Internet of Things will be built on Open SourceAndy Piper
 
Combining Context with Signals in the Internet of Things
Combining Context with Signals in the Internet of ThingsCombining Context with Signals in the Internet of Things
Combining Context with Signals in the Internet of ThingsAndy Piper
 
MQTT - standards-based plumbing for the Internet of Things
MQTT - standards-based plumbing for the Internet of ThingsMQTT - standards-based plumbing for the Internet of Things
MQTT - standards-based plumbing for the Internet of ThingsAndy Piper
 
My Quantified Self and the promise of wearables
My Quantified Self and the promise of wearablesMy Quantified Self and the promise of wearables
My Quantified Self and the promise of wearablesAndy Piper
 
Why Data, Code and Mobile converge in the Open Cloud
Why Data, Code and Mobile converge in the Open CloudWhy Data, Code and Mobile converge in the Open Cloud
Why Data, Code and Mobile converge in the Open CloudAndy Piper
 
From Cloud Computing to Platform as a Service – BCS Oxfordshire
From Cloud Computing to Platform as a Service – BCS OxfordshireFrom Cloud Computing to Platform as a Service – BCS Oxfordshire
From Cloud Computing to Platform as a Service – BCS OxfordshireAndy Piper
 
Why Apps, Data and Mobile Converge in the Open Cloud
Why Apps, Data and Mobile Converge in the Open CloudWhy Apps, Data and Mobile Converge in the Open Cloud
Why Apps, Data and Mobile Converge in the Open CloudAndy Piper
 
The Internet of Things is Made of Signals
The Internet of Things is Made of SignalsThe Internet of Things is Made of Signals
The Internet of Things is Made of SignalsAndy Piper
 
How to Write a Web App in fewer than 140 Characters
How to Write a Web App in fewer than 140 CharactersHow to Write a Web App in fewer than 140 Characters
How to Write a Web App in fewer than 140 CharactersAndy Piper
 
MQTT, Eclipse Paho and Java - Messaging for the Internet of Things
MQTT, Eclipse Paho and Java - Messaging for the Internet of ThingsMQTT, Eclipse Paho and Java - Messaging for the Internet of Things
MQTT, Eclipse Paho and Java - Messaging for the Internet of ThingsAndy Piper
 
Run your Java apps on Cloud Foundry
Run your Java apps on Cloud FoundryRun your Java apps on Cloud Foundry
Run your Java apps on Cloud FoundryAndy Piper
 

Más de Andy Piper (20)

Adapt & Survive
Adapt & SurviveAdapt & Survive
Adapt & Survive
 
Rebooting A Community #DevRelCon
Rebooting A Community #DevRelConRebooting A Community #DevRelCon
Rebooting A Community #DevRelCon
 
Imagining the Future, when the Future is already Now
Imagining the Future, when the Future is already NowImagining the Future, when the Future is already Now
Imagining the Future, when the Future is already Now
 
Developer Advocacy - A Life Less Ordinary
Developer Advocacy - A Life Less OrdinaryDeveloper Advocacy - A Life Less Ordinary
Developer Advocacy - A Life Less Ordinary
 
Twitter in the Internet of Things
Twitter in the Internet of ThingsTwitter in the Internet of Things
Twitter in the Internet of Things
 
Twitter APIs - the starter guide
Twitter APIs - the starter guideTwitter APIs - the starter guide
Twitter APIs - the starter guide
 
Connecting to the pulse of the planet with Twitter APIs
Connecting to the pulse of the planet with Twitter APIsConnecting to the pulse of the planet with Twitter APIs
Connecting to the pulse of the planet with Twitter APIs
 
Internet ALL the Things - a walking tour of MQTT
Internet ALL the Things - a walking tour of MQTTInternet ALL the Things - a walking tour of MQTT
Internet ALL the Things - a walking tour of MQTT
 
Combining Context with Signals in the IoT (longer version)
Combining Context with Signals in the IoT (longer version)Combining Context with Signals in the IoT (longer version)
Combining Context with Signals in the IoT (longer version)
 
Why the Internet of Things will be built on Open Source
Why the Internet of Things will be built on Open SourceWhy the Internet of Things will be built on Open Source
Why the Internet of Things will be built on Open Source
 
Combining Context with Signals in the Internet of Things
Combining Context with Signals in the Internet of ThingsCombining Context with Signals in the Internet of Things
Combining Context with Signals in the Internet of Things
 
MQTT - standards-based plumbing for the Internet of Things
MQTT - standards-based plumbing for the Internet of ThingsMQTT - standards-based plumbing for the Internet of Things
MQTT - standards-based plumbing for the Internet of Things
 
My Quantified Self and the promise of wearables
My Quantified Self and the promise of wearablesMy Quantified Self and the promise of wearables
My Quantified Self and the promise of wearables
 
Why Data, Code and Mobile converge in the Open Cloud
Why Data, Code and Mobile converge in the Open CloudWhy Data, Code and Mobile converge in the Open Cloud
Why Data, Code and Mobile converge in the Open Cloud
 
From Cloud Computing to Platform as a Service – BCS Oxfordshire
From Cloud Computing to Platform as a Service – BCS OxfordshireFrom Cloud Computing to Platform as a Service – BCS Oxfordshire
From Cloud Computing to Platform as a Service – BCS Oxfordshire
 
Why Apps, Data and Mobile Converge in the Open Cloud
Why Apps, Data and Mobile Converge in the Open CloudWhy Apps, Data and Mobile Converge in the Open Cloud
Why Apps, Data and Mobile Converge in the Open Cloud
 
The Internet of Things is Made of Signals
The Internet of Things is Made of SignalsThe Internet of Things is Made of Signals
The Internet of Things is Made of Signals
 
How to Write a Web App in fewer than 140 Characters
How to Write a Web App in fewer than 140 CharactersHow to Write a Web App in fewer than 140 Characters
How to Write a Web App in fewer than 140 Characters
 
MQTT, Eclipse Paho and Java - Messaging for the Internet of Things
MQTT, Eclipse Paho and Java - Messaging for the Internet of ThingsMQTT, Eclipse Paho and Java - Messaging for the Internet of Things
MQTT, Eclipse Paho and Java - Messaging for the Internet of Things
 
Run your Java apps on Cloud Foundry
Run your Java apps on Cloud FoundryRun your Java apps on Cloud Foundry
Run your Java apps on Cloud Foundry
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Twitter APIs for #MediaHackday

  • 1. Twitter APIs Andy Piper Developer Advocate @andypiper
  • 2. Twitter APIs deal both with 
 the moment and the past
  • 3. The Moment: Streaming API t.co/streaming 1% sample, or track keywords The Past: REST API
 t.co/rest Optimize your calls
  • 4. 4 Create your app: easy
 t.co/apps
 
 Don’t re-invent the wheel: libs t.co/libs
  • 6. Help? Join the conversation in the Twitter Community forums Follow @TwitterAPI, @AdsAPI and @TwitterDev for platform updates
  • 7. Developer Resources Documentation dev.twitter.com Streaming API t.co/streaming REST API t.co/rest Create App t.co/apps
 Open Source Libs t.co/libs Code Examples t.co/code
  • 8.
  • 10. A D S A P I t.co/adsapi
  • 11. G E T T I N G S TA R T E D
  • 12. </> PRE-REQUISITES SETUP RUBY VERSION $ ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] $ gem install pry jsonpretty twurl INSTALLING TOOLS & DEPENDENCIES Note: Depending on how your Ruby installation is setup, you may need to run the above “gem install” commands with “sudo”.
  • 13. AUTHORIZATION More info at: https://dev.twitter.com/oauth OAUTH 1.0A The Ads API uses OAuth 1.0a for authorization and implements the 3-legged OAuth flow.
  • 14. AUTHORIZATION API key and secret are available under the “Keys and Access Tokens” tab. CONSUMER KEY & SECRET Your consumer key is a publicly visible identifier for your app. You should never share your consumer secret.
  • 15. </> PRE-REQUISITES SETUP AUTHORIZATION $ twurl authorize --consumer-key key --consumer-secret secret VALIDATE SETUP $ cat ~/.twurlrc TRY IT OUT $ twurl -H ads-api-sandbox.twitter.com "/1/accounts" | jsonpretty
  • 16. PER MINS / ENDPOINT 25 REQUESTS READS PER MIN / CATEGORY 100 REQUESTS WRITES D E V E LO P E R R AT E L I M I TS More info at: https://dev.twitter.com/ads/basics/rate-limiting
  • 17. W O R K S H O P
  • 18. </> INSTALLING THE RUBY SDK $ gem install twitter-ads RUBY SDK SETUP $ twitter-ads twitter-ads v0.3.4 >> START AN INTERACTIVE SESSION Note: Depending on how your Ruby installation is setup, you may need to run the above “gem install” commands with “sudo”.
  • 19. </> RUBY SDK CLIENT # enable sandbox mode CLIENT.options[:sandbox] = true # load up the account instance account = CLIENT.accounts.first # enable request tracing (optional, = true good for troubleshooting) CLIENT.options[:trace] http://bit.ly/ads-api-client
  • 20. </>http://bit.ly/ads-api-campaign RUBY SDK CAMPAIGN # create campaign = TwitterAds::Campaign.new(account) your campaign campaign.funding_instrument_id = account.funding_instruments.first.id campaign.daily_budget_amount_local_micro = 1_000_000 campaign.name = 'my first campaign' campaign.paused = true campaign.start_time = Time.now.utc campaign.save
  • 21. </>http://bit.ly/ads-api-line-item RUBY SDK LINE ITEM # create a line item for the campaign line_item = TwitterAds::LineItem.new(account) line_item.name = 'my first ad' line_item.product_type = TwitterAds::Product::PROMOTED_TWEETS line_item.placements = [TwitterAds::Placement::ALL_ON_TWITTER] line_item.objective = TwitterAds::Objective::TWEET_ENGAGEMENTS line_item.bid_amount_local_micro = 10_000 line_item.paused = true line_item.save line_item.campaign_id = campaign.id
  • 23. </>http://bit.ly/ads-api-promoted-tweet RUBY SDK PROMOTED TWEET # create resource request for a simple null-casted tweet = "/1/accounts/#{account.id}/tweet" tweet_params = { status: ‘Hello @AdsAPI!’ } request = TwitterAds::Request.new(CLIENT, :post, resource, params: tweet_params) tweet = request.perform # promote the tweet using our line item promoted_tweet = TwitterAds::Creative::PromotedTweet.new(account) promoted_tweet.line_item_id = line_item.id promoted_tweet.tweet_id = tweet.body[:data][:id] promoted_tweet.save
  • 24. </>http://bit.ly/ads-api-targeting RUBY SDK TARGETING # fetching targeting criteria values resource = '/1/targeting_criteria/locations' params = { location_type: 'COUNTRY', q: 'u' } request = TwitterAds::Request.new(CLIENT, :get, resource, params: params) cursor = TwitterAds::Cursor.new(nil, request) # add targeting criteria targeting_criteria = TwitterAds::TargetingCriteria.new(account) targeting_criteria.line_item_id = line_item.id targeting_criteria.targeting_type = 'LOCATION' targeting_criteria.targeting_value = '00a8b25e420adc94' targeting_criteria.save
  • 25. </>http://bit.ly/ads-api-analytics RUBY SDK ANALYTICS # limit request count and grab the first 10 line items from TwitterAds::Cursor line_items = account.line_items(nil, count: 10)[0..9] # the list of metrics we want to fetch metrics = [:billed_engagements, :billed_follows] # fetching stats on the instance line_items.first.stats(metrics) # fetching stats for multiple line items ids = line_items.map { |line_item| line_item.id } TwitterAds::LineItem.stats(account, ids, metrics)