Advertisement
Nokidoc

Instagram Arduino

Jan 2nd, 2019
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. #include <MAX7219_Dot_Matrix.h>
  2. #include <MAX7219_Dot_Matrix_font.h>
  3.  
  4. /*******************************************************************
  5. * An example of usisng the InstagramStats library to get
  6. * info on a given user.
  7. *
  8. * Written by Brian Lough
  9. * https://www.youtube.com/channel/UCezJOfu7OtqGzd5xrP3q6WA
  10. *******************************************************************/
  11.  
  12. #include "InstagramStats.h"
  13.  
  14. // ----------------------------
  15. // Standard Libraries - Already Installed if you have ESP8266 set up
  16. // ----------------------------
  17.  
  18. #include <ESP8266WiFi.h>
  19. #include <WiFiClientSecure.h>
  20.  
  21. // ----------------------------
  22. // Additional Libraries - each one of these will need to be installed.
  23. // ----------------------------
  24.  
  25. #include "JsonStreamingParser.h"
  26. // Used to parse the Json code within the library
  27. // Available on the library manager (Search for "Json Streamer Parser")
  28. // https://github.com/squix78/json-streaming-parser
  29.  
  30. //------- Replace the following! ------
  31. char ssid[] = "Nokidoc WLAN 7270"; // your network SSID (name)
  32. char password[] = "xxx"; // your network key
  33.  
  34. WiFiClientSecure client;
  35. InstagramStats instaStats(client);
  36.  
  37. unsigned long delayBetweenChecks = 60000; //mean time between api requests
  38. unsigned long whenDueToCheck = 0;
  39.  
  40. //Inputs
  41. String userName = "duesseldorfhautnah"; // from their instagram url https://www.instagram.com/duesseldorfhautnah/
  42.  
  43.  
  44. void setup() {
  45.  
  46. Serial.begin(115200);
  47.  
  48. // Set WiFi to station mode and disconnect from an AP if it was Previously
  49. // connected
  50. WiFi.mode(WIFI_STA);
  51. WiFi.disconnect();
  52. delay(100);
  53.  
  54. // Attempt to connect to Wifi network:
  55. Serial.print("Connecting Wifi: ");
  56. Serial.println(ssid);
  57. WiFi.begin(ssid, password);
  58. while (WiFi.status() != WL_CONNECTED) {
  59. Serial.print(".");
  60. delay(500);
  61. }
  62. Serial.println("");
  63. Serial.println("WiFi connected");
  64. Serial.println("IP address: ");
  65. IPAddress ip = WiFi.localIP();
  66. Serial.println(ip);
  67. }
  68.  
  69. void getInstagramStatsForUser() {
  70. Serial.println("Getting instagram user stats for " + userName );
  71. InstagramUserStats response = instaStats.getUserStats(userName);
  72. Serial.println("Response:");
  73. Serial.print("Number of followers: ");
  74. Serial.println(response.followedByCount);
  75. }
  76.  
  77. void loop() {
  78. unsigned long timeNow = millis();
  79. if ((timeNow > whenDueToCheck)) {
  80. getInstagramStatsForUser();
  81. whenDueToCheck = timeNow + delayBetweenChecks;
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement