Skip to content

Commit 3b8cfbd

Browse files
committed
Fixing example
1 parent 91d58c7 commit 3b8cfbd

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ I am hoping to make this a little more simple going forward, as we should be abl
2020
- Get curl on your machine ([Windows: try this](http://callejoabel.blogspot.co.uk/2013/09/making-curl-work-on-windows-7.html) it shoud already be installed on mac and linux)
2121
- Make the following request using the key and token from the above section
2222
```
23-
curl -u "$CONSUMER_KEY:$CONSUMER_SECRET" --data 'grant_type=client_credentials' 'https://api.twitter.com/oauth2/token'
23+
curl -u "CONSUMER_KEY:CONSUMER_SECRET" --data 'grant_type=client_credentials' 'https://api.twitter.com/oauth2/token'
2424
```
2525
- The response will contain a bearer token (it is the big long one!), use this with the setBearerToken [as shown in the example](https://github.com/witnessmenow/arduino-twitter-api/blob/master/examples/esp8266/settingBearerTokenInSketch/settingBearerTokenInSketch.ino).

examples/esp8266/settingBearerTokenInSketch/settingBearerTokenInSketch.ino

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <TwitterApi.h>
22

33
/*******************************************************************
4-
* An example of usisng the distance-matrix api to get *
5-
* travel time (with traffic) between two locations *
4+
* An Example of getting data back from the TwitterAPI *
5+
* https://github.com/witnessmenow/arduino-twitter-api *
66
* *
77
* Written by Brian Lough *
88
*******************************************************************/
@@ -16,8 +16,7 @@ char ssid[] = "SSID"; // your network SSID (name)
1616
char password[] = "password"; // your network key
1717

1818
// Normally we would use these to generate the bearer token but its not working yet :/
19-
#define CONSUMER_KEY "consumerkey" //not needed for this sketch as we are setting bearer token directly
20-
#define CONSUMER_SECRET "consumerSecret" // as above
19+
// Use steps on the readme to generate the Bearer Token
2120

2221
#define BEARER_TOKEN "this is long jumble of characters"
2322

@@ -27,7 +26,7 @@ char password[] = "password"; // your network key
2726
// 'https://api.twitter.com/oauth2/token'
2827

2928
WiFiClientSecure client;
30-
TwitterApi api(CONSUMER_KEY, CONSUMER_SECRET, client);
29+
TwitterApi api(client);
3130

3231
unsigned long api_mtbs = 60000; //mean time between api requests
3332
unsigned long api_lasttime = 0; //last time api request has been done
@@ -62,20 +61,6 @@ void setup() {
6261
IPAddress ip = WiFi.localIP();
6362
Serial.println(ip);
6463

65-
// if(api.encodeBearerCredientials()) {
66-
// Serial.println("Encoded bearer creds");
67-
// } else {
68-
// Serial.println("Failed to encode bearer creds");
69-
// return;
70-
// }
71-
//
72-
// if(api.updateBearerToken()) {
73-
// Serial.println("Got bearer token");
74-
// haveBearerToken = true;
75-
// } else {
76-
// Serial.println("Did not get bearer token");
77-
// }
78-
7964
api.setBearerToken(BEARER_TOKEN);
8065
haveBearerToken = true;
8166
getTwitterStats(screenName);
@@ -90,6 +75,7 @@ void getTwitterStats(String name) {
9075
JsonObject& response = jsonBuffer.parseObject(responseString);
9176
if (response.success()) {
9277
Serial.println("parsed Json");
78+
// Use Arduino Json to parse the data
9379
} else {
9480
Serial.println("Failed to parse Json");
9581
}

0 commit comments

Comments
 (0)