Linkedin share plugin not submitting form - javascript

I am using LinkedIn share button on my site with the following html:
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-url="www.aidh.co.uk/blog/1506-exposure/default.html"></script>
The button brings up the Linkedin plug in with all of the content correct and options for sharing.
https://www.linkedin.com/cws/share?url=www.aidh.co.uk%2Fblog%2F1506-exposure%2Fdefault.html&original_referer=http%3A%2F%2Fwww.aidh.co.uk%2Fblog%2F1506-exposure%2Fdefault.html&token=&isFramed=false&lang=en_US&_ts=1432834994124.3257
However the share button on Linkedin's own page doesn't submit the information to Linkedin.
Can anyone help?

Take a look here: Official Microsoft LinkedIn Share API Documentation. It seems like the only valid format is something in the following form...
https://www.linkedin.com/sharing/share-offsite/?url={url}
For example...
https://www.linkedin.com/sharing/share-offsite/?url=http%3A%2F%2Frevoltlib.com%2F
This means that you only have the url param to modify.
If you are interested in a regularly maintained github project that keeps track of this so you don't have to, check it out! Social Share URLs

Read the documentation of LinkedIn plugin.
(https://developer.linkedin.com/docs/share-on-linkedin)

Related

Third party script wont load until page refresh

I run into a problem with my blog that I've been writing content for months now. I'm using Gatsby v2 and the Netlify CMS v2 and host the entire blog with the help of Netlify and Github.
I've asked for help a few days ago but the thread got deleted due to not enough clarification.
So, I'm trying again now.
I'm using this starter: https://github.com/thriveweb/yellowcake , and haven't changed much besides CSS yet.
I'm trying to improve my blog by updating the /src/templates/SinglePost.js template for all my blog posts by adding share buttons from Addthis.com. I've successfully added their code (script) to my blog:
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-545927b3c48573a"></script>
by using Netlifys Snippet injection option. This option allows to inject analytics or other scripts into the HTML of the site before </body> tag.
but since its a static website, If I enter the website from the home URL it doesn't load the script on other pages. I have to refresh (reload) the blog post in order to see the share buttons if I'm coming from the homepage or any other page from the website. Is there a way to refresh the blog posts automatically when a user enters the blog post when he's coming from the homepage?
Looking for solutions :)
You can try something like
<body onload="addScript()">
function addScript() {
var my_script = document.createElement('script');
my_script.setAttribute('src','http.....');
document.head.appendChild(my_script);
}

Google-plus sign in With AngularJs

I am trying to implement google+ signin using https://github.com/sirkitree/angular-directive.g-signin , it is very simple to implement as explained in this module but i am not getting it worked.
below is the js fiddle for the src.
jsfiddle
<div ng-app="directive.g+signin">
<g+signin clientid="620125449078"></g+signin>
<p>This is a Google Plus sign-in button</p>
</div>
You have to use Google's API console to create YOUR OWN client ID which pairs with the domain serving the login button.
Please read the documentation here.

Embed Twitter User Timeline in Webpage

On my website, a user enters their Twitter username when they register and their timeline is embedded on their profile page. Until now, I've achieved this with the following JavaScript code:
<script type="text/javascript">
var twitterUsername = // read from database
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 4,
interval: 30000,
width: 'auto',
height: 210,
features: {
scrollbar: true,
loop: false,
live: false,
behavior: 'all'
}
}).render().setUser(twitterUsername).start();
</script>
Recently I noticed the following messages appearing in the JavaScript console
TWITTER WIDGET: This widget is being deprecated, and will cease functioning soon. https://twitter.com/support/status/307211042121973760
TWITTER WIDGET: You can obtain a new, upgraded widget from https://twitter.com/settings/widgets/new/user?screen_name=electricpicnic
It seems that instead of using this widget I should use an embedded timeline. However, the docs seem to suggest that in order to embed a timeline in a page, you need to go to the widgets section of your settings page and setup a widget for each user whose timeline you wish to embed. Twitter gives you the code that will embed this timeline in your page, but this code contains an attribute data-widget-id="275025608696795138" which has a different value for each user.
Obviously this approach won't work for me, because it's not feasible for me to setup a widget for all my users (present and future) and store a data-widget-id for each of them. Is there some non-deprecated way that I can embed timelines, which allows me to provide the Twitter username at runtime?
Update
According to this post in the Twitter dev discussion group, this functionality is not available currently, but will be provided in a future version.
Twitter is deprecating their unauthenticated widgets. You will no longer be able to use those.
But Twitter has an API that you can call, and you can generate your own custom tweet timeline UI without having to use their widget. For an example of the UI, see http://tweet.seaofclouds.com/.
But you also have to know that you just can't call their API directly from Javascript, since their API has OAuth. You can call their API only from server-side code (I don't know what you're using now, PHP/Ruby/Python/Java?). Good news is, OAuth is an open standard and you can call their API using any language. Here is an example of the same widget, but it gets data by calling the API using PHP. This is a long term solution.
If the Twitter timeline is essential for your site - then you have to go the API way. You must register your site with Twitter, and then use OAuth to get a user's timeline data, and use that data to render the javascript widget.
With the new Twitter widgets, just create an authenticated twitter widget from your own account (e.g. YourName).
Then set the data-screen-name of the user (e.g. 'twitterUsername') you want to show and you end up with something like this:
<a class='twitter-timeline' href='https://twitter.com/YourName'
data-widget-id='your-widget-id'
data-screen-name='twitterUsername'>Tweets by #twitterUsername</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','twitter-wjs');</script>
Here is a bit of javascript that you can use to embed a user's timeline in a webpage
Add the script https://www.tweetjs.com/tweetjs.js
Then add the code:
TweetJs.ListTweetsOnUserTimeline("PetrucciMusic",
function (tweets) {
for(var i in tweets)
{
document.write(tweets[i].text + "<br>");
}
});
... Although I'd recommend using better styling than that :)
This is how I use it, feels pretty decent.
HTML:
<ul id="twitter_update_list">
</ul>
Script:
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=theunexpected1&callback=twitterCallback2&count=10"></script>
Notice the "screen_name" variable sent out to the script.
You can customize your callback function (blogger.js), also you can save this file locally to avoid external request.
Hope this is useful.
For reference, I have created a jsfiddle here, you can take the CSS snippets too from there.
http://jsfiddle.net/rahulsv/8fRTD/
UPDATE:
This solution no longer works since Twitter updated to v1.2 - no unauthorized access to tweets.

facebook comments - doesn't let me moderate

I'm trying to install facebook comments on my page, but it doesn't let me moderate. On a test page with only the comments plugin - no problem. the same code exactly on a live page - doesn't let me moderate.
the test page:
http://www.radicalislam.org/test3.html
the live page:
http://www.radicalislam.org/news/pakistan-hands-huge-prison-sentence-bin-laden-informant
tried to debug, it shows the right admin and app id.
it's a drupal site, if it's important
Looks like you are using partial URLs for the href. Use the full one.
Use the following instead.
<div class="fb-comments" href="http://www.radicalislam.org/news/pakistan-hands-huge-prison-sentence-bin-laden-informant" data-num-posts="5" data-width="580"></div>
Unfortunately my work Firewall wouldn't let me click through to the link.
Are you using the correct URL when you add the Facebook comments to the page? If you aren't you won't be able to moderate, you will likely need to dynamically add the URL to the generated code.
Have you tried scraping the page using the debug tool (as the admin)?
http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.radicalislam.org%2Ftest3.html
This will read the updated admin IDs and let the administrator see the moderation panel in the plugin and via https://developers.facebook.com/tools/comments

how to create a content sharing service like Tweet button or Facebook share

I am implementing a content sharing service, similar to Twitter and Facebook button. When the user visits a page, he will be able to click on my button, which will open a page in a new window that lets the user interact with my service. My service use 2 parameters: the current page's URL and title.
I have looked at the html code used to add the Twitter, Facebook and Printfriendly buttons and they all use Javascript code specific to their service.
For instance, this JS file must be included to add the Printfriendly button to your page:
<script src="http://cdn.printfriendly.com/printfriendly.js" type="text/javascript"></script>
For Facebook: <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
Twitter:<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
My question is do I need to write some Javascript code or can I just forward all the request to the server?
Thanks,
Olivier.
You need to write a bit of JavaScript code for the button (for the window to show up with the specified contents) and the main script (which is included like Twitter and facebook did as you mentioned)
You can get away with simple hyperlink. For example Facebook share button works like hyperlink: Share on Facebook.
The reason to use javascript or iframe is to have better control over user experience. So it is up to you to decide how you want to handle it.

Categories