Closed nickcernis closed 7 years ago
ok, pushed a fix for this to master, develop, rainmaker-master, and rainmaker-develop. Pick your poison to test it.
Test Scenario:
Note It seems LinkedIn is blocking requests via the JS so we may need additional workaround to get the counts back.
Test Verification:
Other Features/Areas Affected: N/A
ok, found a solution that works for LinkedIn to get the counts despite the API changes
Thanks, Nick! Looks good in WordPress [http://debug.wpdemo.me/test-word-wrapping/ ]:
Have not tested Rainmaker yet.
In case the PHP count fallback causes problems for any users, an alternative fix may be to specify the JS callback function name manually to exclude punctuation and numbers. i.e. Use $.ajaxSetup({ jsonpCallback: "simpleShare" });
before using $.getJSON()
in jquery.sharrre.js
around line 490. (We have seen support issues with the PHP count method used for Google+ due to server security rules, but not very often – happy to monitor this.)
We have seen support issues with the PHP count method used for Google+ due to server security rules, but not very often – happy to monitor this
The issue is more than just the callback. When I removed that and tested I got a different fail error based on the domain not being allowed. It seems LinkedIn changed their security and are now blocking the JS request methods like this. Which is why I had to rewrite to use the .php file, not dealing with the callback itself.
When I removed that and tested I got a different fail error based on the domain not being allowed.
Removing the callback=?
param altogether turns the JSONP request into a regular JSON one, I believe:
If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details. – http://api.jquery.com/jQuery.getJSON/#jsonp
A JSON request will trigger the cross-domain error you saw because JSON requests are subject to the same-origin policy, unlike JSONP. I get the same error when pasting jQuery.getJSON('https://www.linkedin.com/countserv/count/share?format=jsonp&url=http%3A%2F%2Fexample.com%2F', function (json) { console.log(json); });
into the console on http://www.copyblogger.com/email-marketing-defined/, for example (missing callback
param drops the request to JSON).
Seems crazy that LinkedIn would start validating the callback parameter name all of a sudden. Your PHP idea is really smart and looks good – thank you for jumping on this so fast.
Just waiting on RM sites to update to test it there. (I am still currently seeing LinkedIn errors on http://nick-cernis.pro01.rmkr.net/admin/admin.php?page=universal-settings&tab=traffic still.)
The RM sites should have updated by now. Likely you have cached JS.
Hmm. I used Empty Cache and Hard Reload and tried two other browsers but don't see the latest JS. Guessing http://nick-cernis.pro01.rmkr.net/
may not be updating hourly.
@katyfb13 Please could I have your help testing this fix for Rainmaker at some point?
/admin/admin.php?page=universal-settings&tab=traffic
when LinkedIn is checked in the settings at the bottom of that page.I can verify that the LinkedIn button shows on the cbmdev02 site, on the "develop" branch.
This is deployed for WP.org as version 1.0.7
closing as this should be in production
We have seen several reports of broken LinkedIn share buttons in Rainmaker support today. The LinkedIn button is not loading or displaying the count. Demo URLs:
The console shows a 400 (Bad Request) error against the LinkedIn count API URL:
https://www.linkedin.com/countserv/count/share?format=jsonp&url=http%3A%2F%2Fwww.copyblogger.com%2Femail-marketing-defined%2F&callback=jQuery111302880242855132005_1463058833340&_=1463058833341
Visiting that link shows an “invalid callback parameter” message.
Findings so far
LinkedIn's API seems to now reject callback parameters that contain numbers or punctuation.
This request works (contains
&callback=abc
):https://www.linkedin.com/countserv/count/share?format=jsonp&url=http%3A%2F%2Fgrowprogram.com%2Fsnapchat-insurance-agents%2F&callback=abc
But these return a 400 “bad request” response and show an “Invalid callback parameter” error (
&callback=123
or&callback=abc123
or&callback=a_b_c
):