SlideShare une entreprise Scribd logo
INTERNET OF THINGS
WORKSHOP - RASPBERRY PI
DES ATELIERS DE TRAVAIL SUR LES OBJETS CONNECTÉS ET LE RASPBERRY PI
#ITRONICS_IOT_WORKSHOP
C’EST QUOI “L’API TWITTER”
C’est un API permettant au raspberry d’interagir avec twitter.
- Faire des Tweets
- Répondre à un Tweet
- Espionner la publication d’un contenu particulier
FAIRE UN TWEET
Le raspberry pi peut poster un petit message d’une taille de 140max sur Twitter.
RE-TWITTER
Le raspberry pi peut ainsi répondre à un message précédement posté.
ESPIONNER TWITTER
Le raspberry pi peut surveiller la file de publication pour détecter un contenu précis.
TWYTHON, C’EST QUOI?
Twyton est un bibliothèque permettant au raspberry pi de réaliser ce cité
précédement.
PRÉPARATION DU RASPBERRY PI
- Sudo apt-get update
- Sudo apt-get install python-pip
- Sudo pip install twython
ENREGISTREMENT SUR TWITTER
Aller sur twitter.com et créer un compter
Vous recevrez plusieurs « clés ». (4 clés)
Twython utiliser ces « clés ».
RECUPÉRATION DES “CLÉS”
Aller sur apps.twitter.com et créer une application
Recupérez les details de l’application
1- « Consumer Key »
RECUPÉRATION DES “CLÉS”
Aller dans l’onglet « Keys and Access Tokens»
Relever:
1- « Consumer Key »
2- « Consumer Secret »
CRÉER LES CLÉS D’ACCES
Aller dans l’onglet « Create my Access Tokens »
Relever:
1- « Access Token »
2- « Access Token Secret »
ENFIN FAIRE UN TWEET
Utilisons les 4 « clés »Pour
créer un objet twython.
TWYTHON STREAMER
From twython import Twython
C_KEY = « ????????? »
C_SECRET = « ????????? »
A_TOKEN = « ????????? »
A_SECRET = « ????????? »
Api = Twython (C_KEY, C_SECRET, A_TOKEN, A_SECRET)
Api.update_status(« Hi »)
PUIS, ESPIONNONS UN PEU
Recherchons un Hashtag
particulier.
TWYTHON STREAMER
From twython import Twython
C_KEY = « ????????? »
C_SECRET = « ????????? »
A_TOKEN = « ????????? »
A_SECRET = « ????????? »
#Api = Twython (C_KEY, C_SECRET, A_TOKEN, A_SECRET)
#Api.update_status(« Hi »)
TWYTHON STREAMER
---
Class MyStreamer(TwythonStreamer)
Def on_success(self, data):
if ‘text’ in data:
print(‘’Found it.’’)
Stream = MyStreamer(C_KEY, C_SECRET, A_TOKEN, A_SECRET)
Stream.statuses.filter(track=‘‘iTronics’’)
REPONDRE PAR UN CLIGNOTEMENT
DE LED
---
Def blink():
GPIO.output(13, GPIO.HIGH)
time.sleep(1)
GPIO.output(13, GPIO.LOW)
Class MyStreamer(TwythonStreamer)
Def on_success(self, data):
if ‘text’ in data:
print(‘’Found it.’’)
Stream = MyStreamer(C_KEY, C_SECRET, A_TOKEN, A_SECRET)
Stream.statuses.filter(track=‘‘iTronics’’)
THANKS FOR YOUR
KIND ATTENTION !!!
A suivre…

Contenu connexe

Plus de Romaric Saounde Tsopnang

Plus de Romaric Saounde Tsopnang (20)

An color Sensor - Beginner
An   color Sensor - BeginnerAn   color Sensor - Beginner
An color Sensor - Beginner
 
Al capteur tactile - Débutant
Al   capteur tactile - DébutantAl   capteur tactile - Débutant
Al capteur tactile - Débutant
 
Al touch2 - Beginner
Al   touch2 - BeginnerAl   touch2 - Beginner
Al touch2 - Beginner
 
Ak custom imagessounds2 - Beginner
Ak   custom imagessounds2 - BeginnerAk   custom imagessounds2 - Beginner
Ak custom imagessounds2 - Beginner
 
Ak image et son standard - Débutant
Ak   image et son standard - DébutantAk   image et son standard - Débutant
Ak image et son standard - Débutant
 
Aj display2 - Beginner
Aj   display2 - BeginnerAj   display2 - Beginner
Aj display2 - Beginner
 
Aj affichage - Débutant
Aj   affichage - DébutantAj   affichage - Débutant
Aj affichage - Débutant
 
Ai turning2 - Beginner
Ai   turning2 - BeginnerAi   turning2 - Beginner
Ai turning2 - Beginner
 
Ai virages - Débutant
Ai   virages - DébutantAi   virages - Débutant
Ai virages - Débutant
 
Ah pseudocode2 - Beginner
Ah   pseudocode2 - BeginnerAh   pseudocode2 - Beginner
Ah pseudocode2 - Beginner
 
Ah pseudocode-fr - Débutant
Ah   pseudocode-fr - DébutantAh   pseudocode-fr - Débutant
Ah pseudocode-fr - Débutant
 
Ag moving straight2 - Beginner
Ag   moving straight2 - BeginnerAg   moving straight2 - Beginner
Ag moving straight2 - Beginner
 
Ag deplacement droit - Débutant
Ag   deplacement droit - DébutantAg   deplacement droit - Débutant
Ag deplacement droit - Débutant
 
Af port view2 - Beginner
Af   port view2 - BeginnerAf   port view2 - Beginner
Af port view2 - Beginner
 
Af vue des portes - Débutant
Af   vue des portes - DébutantAf   vue des portes - Débutant
Af vue des portes - Débutant
 
Ae common issues2 - Beginner
Ae   common issues2 - BeginnerAe   common issues2 - Beginner
Ae common issues2 - Beginner
 
Ae problemes frequents - Débutant
Ae   problemes frequents - DébutantAe   problemes frequents - Débutant
Ae problemes frequents - Débutant
 
Ac introduction2 - Beginner
Ac   introduction2 - BeginnerAc   introduction2 - Beginner
Ac introduction2 - Beginner
 
Ac introduction-fr - Débutant
Ac   introduction-fr - DébutantAc   introduction-fr - Débutant
Ac introduction-fr - Débutant
 
Ab installing updates2 - Beginner
Ab   installing updates2 - BeginnerAb   installing updates2 - Beginner
Ab installing updates2 - Beginner
 

3- The iTronics Internet of things Workshop 27-05-2017 - Twitter API

  • 1. INTERNET OF THINGS WORKSHOP - RASPBERRY PI DES ATELIERS DE TRAVAIL SUR LES OBJETS CONNECTÉS ET LE RASPBERRY PI #ITRONICS_IOT_WORKSHOP
  • 2.
  • 3. C’EST QUOI “L’API TWITTER” C’est un API permettant au raspberry d’interagir avec twitter. - Faire des Tweets - Répondre à un Tweet - Espionner la publication d’un contenu particulier
  • 4. FAIRE UN TWEET Le raspberry pi peut poster un petit message d’une taille de 140max sur Twitter.
  • 5. RE-TWITTER Le raspberry pi peut ainsi répondre à un message précédement posté.
  • 6. ESPIONNER TWITTER Le raspberry pi peut surveiller la file de publication pour détecter un contenu précis.
  • 7. TWYTHON, C’EST QUOI? Twyton est un bibliothèque permettant au raspberry pi de réaliser ce cité précédement.
  • 8. PRÉPARATION DU RASPBERRY PI - Sudo apt-get update - Sudo apt-get install python-pip - Sudo pip install twython
  • 9. ENREGISTREMENT SUR TWITTER Aller sur twitter.com et créer un compter Vous recevrez plusieurs « clés ». (4 clés) Twython utiliser ces « clés ».
  • 10. RECUPÉRATION DES “CLÉS” Aller sur apps.twitter.com et créer une application Recupérez les details de l’application 1- « Consumer Key »
  • 11. RECUPÉRATION DES “CLÉS” Aller dans l’onglet « Keys and Access Tokens» Relever: 1- « Consumer Key » 2- « Consumer Secret »
  • 12. CRÉER LES CLÉS D’ACCES Aller dans l’onglet « Create my Access Tokens » Relever: 1- « Access Token » 2- « Access Token Secret »
  • 13. ENFIN FAIRE UN TWEET Utilisons les 4 « clés »Pour créer un objet twython.
  • 14. TWYTHON STREAMER From twython import Twython C_KEY = « ????????? » C_SECRET = « ????????? » A_TOKEN = « ????????? » A_SECRET = « ????????? » Api = Twython (C_KEY, C_SECRET, A_TOKEN, A_SECRET) Api.update_status(« Hi »)
  • 15. PUIS, ESPIONNONS UN PEU Recherchons un Hashtag particulier.
  • 16. TWYTHON STREAMER From twython import Twython C_KEY = « ????????? » C_SECRET = « ????????? » A_TOKEN = « ????????? » A_SECRET = « ????????? » #Api = Twython (C_KEY, C_SECRET, A_TOKEN, A_SECRET) #Api.update_status(« Hi »)
  • 17. TWYTHON STREAMER --- Class MyStreamer(TwythonStreamer) Def on_success(self, data): if ‘text’ in data: print(‘’Found it.’’) Stream = MyStreamer(C_KEY, C_SECRET, A_TOKEN, A_SECRET) Stream.statuses.filter(track=‘‘iTronics’’)
  • 18. REPONDRE PAR UN CLIGNOTEMENT DE LED --- Def blink(): GPIO.output(13, GPIO.HIGH) time.sleep(1) GPIO.output(13, GPIO.LOW) Class MyStreamer(TwythonStreamer) Def on_success(self, data): if ‘text’ in data: print(‘’Found it.’’) Stream = MyStreamer(C_KEY, C_SECRET, A_TOKEN, A_SECRET) Stream.statuses.filter(track=‘‘iTronics’’)
  • 19. THANKS FOR YOUR KIND ATTENTION !!! A suivre…