jaredatch / EA-Share-Count

A lean plugin that leverages SharedCount.com API to quickly retrieve, cache, and display various social sharing counts.
84 stars 13 forks source link

Lost all Facebook counts #83

Closed emmtre closed 7 years ago

emmtre commented 7 years ago

I have several websites that have lost all Facebook counts in the database. But it looks like the total social sharing counts still are correct in the database. I have recently updated Genesis to 2.5.0, WordPress to 4.7.5 and PHP from 7.0.x to 7.1.4 on all websites. And the problem started sometimes after those updates. Some websites have separate Facebook access tokens I have created earlier but not all websites. I have tried to find any potential problems by using WP Debug and Query Monitor but I don't see any real problems and just some minor PHP notices. So I have created a new access token for one website but I don't see any API calls in the Facebook dashboard. Can it be a problem with the generated access token or have Facebook changed something recently or have I the wrong settings for the Facebook app or are the calls blocked by my hosting? Any ideas or tips why it's not working anymore?

Database:

ea_share_count  {"Facebook":{"share_count":0,"like_count":0,"comment_count":0,"total_count":0},"Twitter":0,"Pinterest":0,"LinkedIn":0,"GooglePlusOne":"0","StumbleUpon":0}
ea_share_count_datetime  1495305422
ea_share_count_total  135

PHP Notices:

Undefined index: before in /wp-content/plugins/ea-share-count/includes/class-front.php on line 115
Undefined index: before in /wp-content/plugins/ea-share-count/includes/class-front.php on line 117
Undefined index: after in /wp-content/plugins/ea-share-count/includes/class-front.php on line 122
Undefined index: after in /wp-content/plugins/ea-share-count/includes/class-front.php on line 124
jaredatch commented 7 years ago

When you get a chance, you may try using 1.9 which is currently in beta (it was labeled originally 1.8.1 but it will be released as 1.9 https://github.com/jaredatch/EA-Share-Count/tree/v1.8.1)

It fixed a few bugs, though I don't believe it had any affect on facebook.

After you update to 1.9, open the Chrome developer console, edit one of your posts, and hit refresh in the metabox. What displays in the console?

Also, can you let me know a URL on your site for testing?

emmtre commented 7 years ago

Well, there are no errors in the console that I can see with the current stable 1.8 or the beta 1.8.1.

[Log] Object (admin-metabox.js, line 20)
data: {msg: "Share counts updated.", class: "success", date: "<p id=\"ea-share-count-date\">Last updated May 24, 2017 7:01pm</span></p>", list: "<ul id=\"ea-share-count-list\"><li>Facebook Likes: <…</li><li>StumbleUpon: <strong>0</strong></li><ul>"}
success: true
Object Prototype
[Log] Object (admin-metabox.js, line 20)
data: Object
class: "success"
date: "<p id=\"ea-share-count-date\">Last updated May 24, 2017 7:01pm</span></p>"
list: "<ul id=\"ea-share-count-list\"><li>Facebook Likes: <strong>0</strong></li><li>Facebook Shares: <strong>0</strong></li><li>Facebook Comments…"
msg: "Share counts updated."
Object Prototype
success: true
Object Prototype

After installing the beta 1.8.1 I can get the Facebook counts back again by refreshing the counts.

So there must have been some issue caused by the update to PHP 7.1.4/5 or the other updates.

But only when removing the Facebook access token and and re-saving the share count settings.

So the beta 1.8.1 did help but there still are some problems with the Facebook access token.

Can you please post a screen shoot of the different Facebook app settings so I can compare?

The site url and app domains are ok and I have set the category to apps for pages and made public.

Or is the generated access token not working anymore sine I don't see any calls in the dashboard?

emmtre commented 7 years ago

But there is a console error sometimes when I update or save a post but it looks normal.

[Error] XMLHttpRequest cannot load https://website.com/wp-admin/admin-ajax.php due to access control checks.
    send (load-scripts.php:4:26582)
    ajax (load-scripts.php:4:22185)
    j (load-scripts.php:4:2643)
    (anonymous function) (load-scripts.php:4:3381)
billerickson commented 7 years ago

Are you running http on the frontend of the site but https on the backend?

I've seen an issue similar to this when building a site on WPEngine. We were using http on the frontend but they force https on the backend, which broke any scripts on the frontend that used admin ajax (the "Share via email" didn't actually send an email). I think I fixed it by using https everywhere.

emmtre commented 7 years ago

No, the websites we have at DigitalOcean are using https both on the front and backend. And the website we have on different shared hosting are using http.

But I just noticed the admin-ajax.php link above is to https?

Are you using Facebook access token on all websites you are building for clients to be able to get Facebook counts or does it still work without for all websites?

billerickson commented 7 years ago

It's been a while since I've built a site that needed Facebook share counts (we typically do buttons without counts), but on most sites it seemed to work without the access token.

Based on my testing I think Facebook throttles based on IP address, so shared hosting environments are more likely to require access tokens if other sites using that same IP have been making many requests.

The SharedCount service is available again, so it might be worth filtering the API queries to use that instead (see this filter).

jaredatch commented 7 years ago

I can't provide much input in the Facebook access tokens because I haven't worked much with that (Bill wrote the original implementation).

What I can say is with the 1.9 beta (labeled 1.8.1) I purposely added support BACK for SharedCount service, because IMO its easier rely on and also lets you do one request instead of 3-4, so it's much more performant.

Check out https://github.com/jaredatch/EA-Share-Count/wiki/SharedCount.com-Support