Closed dreamwhisper closed 6 years ago
Noting the Facebook API supports multiple URLs in a single request:
It's increasingly common for users to move to HTTPS and lose their share counts, so we're still asked about this. For example: https://wordpress.org/support/topic/facebook-share-cont-lost-after-migration-to-https?replies=2#post-8714649
Instead of pulling both, the simpler solution will be to specify one or the other. However, I'll see if there is a way to make it work with both because more and more sites will have to make this switch.
@NicktheGeek The Facebook badge counts HTTP URLs for HTTPS pages after this change. This could reset counts to zero on sites that have always served posts over HTTPS, so I'm not sure it's right.
Tested by:
functions.php
:
add_filter( 'post_link', 'fake_permalink' );
add_filter( 'page_link', 'fake_permalink' );
function fake_permalink( $permalink ) {
return 'https://example.com';
}
Expected to see:
Actually see:
This is interesting. Originally I had it serving the combined values, but then I was seeing double values because it seemed Facebook was serving the combined count so I made it not use that. Now it seems they are doing the count segregated again.
curious, it seems if FB doesn't have both http and https for a given url it returns what they do have. https://graph.facebook.com/?id=https://www.copyblogger.com/do-not-read-this-post-or-the-kitten-gets-it/ https://graph.facebook.com/?id=http://www.copyblogger.com/do-not-read-this-post-or-the-kitten-gets-it/
Both are showing 131 shares, but there is no way that is correct. That post almost certainly only has http shares.
@nickcernis ok, I've updated the release branch. I'm not sure the best way to make this value accurate since FB apparently will use the https or http share if there isn't both so that some URLs would get a double share count. I opted to check if the count values are exactly the same. If they are it only uses the first value. There will likely be real world scenarios where the http and https values are identical so only one or the other will be used but that is no worse that the current solution where one or the other is used and by and large most share URLs will have different values if there is data for each. I think that is the only reasonable solution I can come up with short of throwing the whole thing out.
Thanks, @NicktheGeek. I'm still seeing 21.40M (the HTTP total) for https://example.com instead of the combined HTTP + HTTPS total (~21.45M):
I'm not sure it's our fault, though. I spotted this in the comments when the Jetpack team tried to solve the same issue:
Facebook protocol summing has been shown to falsely double counts, so we only request the current URL.
So perhaps the counts from FB can't be relied upon, and using the current URL is the best approach after all. Sorry for the pain this caused!
Edited to add: using the larger value of the two seems fine if it will prevent doubling. Setting as confirmed.
@nickcernis I would try a different example URL. The rounding could be getting thrown off.
Also, might be worth making sure your scripts are updated and pulling from the right branch. I'm getting a different value.
Thanks — looks good for other URLs.
From previous conversations related to share counts when switching from http to https, simple share could include both in the total count.