Open D3xtar opened 5 years ago
I can't display the numbers for Facebook. I am using the same sketch. Can someone please help me ?
My Facebook code:
void getFacebookUsers() { if (!secureClient.connect(host, 443)) { Serial.println("connection failed");}
secureClient.verify(fingerprint, host);
String url = "/"+page_url+"/community?locale=en_US"; //
secureClient.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: ESP8266\r\n" +
"Connection: close\r\n\r\n");
while (secureClient.connected()) {
String line = secureClient.readStringUntil('>');
if(line.startsWith("<meta name=\"description\"")){
int st = line.indexOf(".")+2;
int sp = line.indexOf("likes",st)-1;
int st2 = sp + 14;
int sp2 = line.indexOf("talking",st2)-1;
String like = line.substring(st,sp);
String talk = line.substring(st2,sp2);
like.remove(1, 1);
int like_i = (like.toInt());
displayFB.showNumberDec(like_i,leadingzeroes);
Serial.print("Facebook Likes : ");
Serial.println(like);
}
}
}
Remember that this code still has the workaround which i described in my first post.
Thank you for your reply. I have some more questions. I am not really sure which url I should provide. Is it just my Facebook page or do I have to give this this url? AAA?access_token=BBB|CCC&fields=fan_count AAA = Facebook Page ID or name, BBB = App ID CCC = App Secret And do I also need to change the host and the fingerprint?
First: Thank you for sharing this sketch. The Facebook display is a very welcome addition to the original sketch by Becky.
But, when i want to convert the " likes" string toInt with more than 1000 Facebook followers the returning int is " 1" instead of " 1000" . The toInt function does not handle the comma in the " likes" string very well.
For now I fixed this by adding the following line:
like.remove(1, 1);
Which removes the comma in the string. This works, but when my follower count drops below 1000 problems will occur.