-6

I'm trying to get social share links to work but they result in an error.

For example,clicking LinkedIn button results in the following error:

"We're sorry. Something unexpected happened and your request could not be completed. Please try again." so basically no way to post article. I'm running into similar issues for others and for Facebook, I can't get it work even though the SDK is public.

Here's the page

I've created a code pen

var topButtonsVisible = !0,
  bottomButtonsVisible = !1,
  GooglePlusUrl,
  redditUrl,
  bindInviews = function() {
    $("#myShareButtonsBottom").bind("inview", function(a, b) {
      bottomButtonsVisible = b ? !0 : !1
    });
    $("#myShareButtonsTop").bind("inview", function(a, b) {
      topButtonsVisible = b ? !0 : !1
    })
  },
  setShareEvents = function() {
    $(".myFacebookBtn").click(function() {
      FB.ui({
      ...
  • 2
    What are you trying to achieve with the `!0` syntax - that returns the boolean value `true` every time. and in the `bottomsButtonsVisible = b ? !0 : !1` What are you looking to do? – Christopher Messer Aug 13 '17 at 16:35
  • I'm trying to replicate this page https://web.archive.org/web/20160304045701/http://sebastian-kuepers.com/blog/2014/11/28/custom-share-buttons-for-my-squarespace-blog – Call Me Nicholi Aug 13 '17 at 19:23

1 Answers1

1

It's hard to say for this, but from your codepen, it doesn't work and seems you are missing jQuery. You need to have jQuery on the page for any of this to work.

I added jQuery to the codepen and it seems to work with that in place, with the exception of FB. FB also requires their own library to be included on the page.

You can start by adding one of the links from here for jQuery to the page: https://code.jquery.com/

jQuery link needs to be before your script that runs. That should fix most of your issues.

You'll have to comment out your FB call from setHackernewCount(); in your document ready, then all the rest should work.

This page, https://developers.facebook.com/docs/javascript/quickstart should give you what you need (instructions wise) to use the FB.ui javascript API.

UPDATE: After more investigation I do not see this script even on the page you're trying to use it on. You will need to start there and add the script to the page.

lscmaro
  • 995
  • 8
  • 22
  • jQuery is missing in OP CodenPen... But in its page, jQuery 1.11.1 is loaded. **His script isn't**... Which is funny. – Louys Patrice Bessette Aug 13 '17 at 16:50
  • Well that might be the problem. I looked too and didn't find any reference to any code posted here on the site. Maybe a Squarespace thing? – lscmaro Aug 13 '17 at 17:00
  • 1
    Can't say about *SquareSpace*... Never used it. But to debug a script, it's always helpfull to have it loaded. (lol) OP should look over this first. – Louys Patrice Bessette Aug 13 '17 at 17:07
  • Yes it is! I will edit my answer with that info as well :) – lscmaro Aug 13 '17 at 17:11
  • I'm not a coder, try to be gentle. Get him! LOL – Call Me Nicholi Aug 13 '17 at 17:32
  • I'm trying to replicate this page: https://web.archive.org/web/20160304045701/http://sebastian-kuepers.com/blog/2014/11/28/custom-share-buttons-for-my-squarespace-blog – Call Me Nicholi Aug 13 '17 at 17:42
  • 1
    lol ..as funny as it is, we're all sincerely trying to help! Well you have your click handler going on that piece you did I see. So your JS is on the page, his apparently isn't. – lscmaro Aug 13 '17 at 17:43
  • If you add jquery to that codepen and comment out the function I mention in my answer and should work on codepen – lscmaro Aug 13 '17 at 20:49
  • @CallMeNicholi - So I see the codepen firing the social calls to open popup windows, on some (reddit, pintrest).. I'm not sure what else you need from my answer. It should work when you have jQuery and the script on the page for most of your social clicks. You will need to follow the instructions on the link I have in my answer for FB.ui to work. With all of that info I think you should be able to get it. – lscmaro Aug 14 '17 at 00:07
  • I pretty much have everything but now the issue is that it won't work on Squarepace. They minify scripts and when I add it, it does not work. https://developers.squarespace.com/custom-javascript/ - Is there a way to debug ? – Call Me Nicholi Aug 14 '17 at 18:29
  • Is your script on the page? I don't see it on the page you reference in your question. If there are other links and more info, you should also update your question so everyone can follow on this. – lscmaro Aug 14 '17 at 18:43
  • Here's the test page https://nicholas-mcdonough-9ycm.squarespace.com/home/blog - all code should be there. – Call Me Nicholi Aug 18 '17 at 01:33
  • @CallMeNicholi - jQuery is not on your site. Read this: https://answers.squarespace.com/questions/9451/how-can-i-add-jquery-to-my-site.html. – lscmaro Aug 18 '17 at 02:19
  • Ok, I GOT IT. I placed in the wrong place. It works Now. The only thing standing in my way is get the links to function correctly where the title shows etc. This is not my code. – Call Me Nicholi Aug 19 '17 at 02:55
  • other issue is Facebook: Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. – Call Me Nicholi Aug 19 '17 at 02:55
  • @CallMeNicholi - If you think this is the answer to your question maybe you can mark it as the accepted answer, and might I suggest updating your question a little more/better, since you most likely have a better understanding of the issue now :) – lscmaro Aug 21 '17 at 02:52