Étape 6: Comment envoyer un message twitter de Arduino
Envoyer un message twitter, que nous devons obtenir un jeton à partir de Twitter et installer la bibliothèque de Tweet pour Arduino.
Suivez l’étape 3 ci-dessous :
- Faire un ou plusieurs compte pour recevoir un message de tweet d’Arduino twitter.
- Obtenir un jeton pour publier un message utilisant OAuth
- Télécharger bibliothèque twitter attatched et installer comme bibliothèque IRLED dans votre répertoire Arduino installé
- Exécutez ci-dessous esquisse d’échantillon de tweet.
#if defined(ARDUINO) && ARDUINO > 18 // Arduino 0019 or later#include <SPI.h>#endif#include <Ethernet.h>//#include <EhternetDns.h> Only needed in Arduino 0022 or earlier#include <Twitter.h>byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };byte ip[] = { 10, 0, 0, 177 };Twitter twitter("<<< your token here >>>");char msg[] = "Hello, World! I'm Arduino!";void setup(){ delay(1000); Ethernet.begin(mac, ip); Serial.begin(9600); Serial.println("connecting ..."); if (twitter.post(msg)) { int status = twitter.wait(); if (status == 200) { Serial.println("OK."); } else { Serial.print("failed : code "); Serial.println(status); } } else { Serial.println("connection failed."); }}void loop(){}