Sharing dymanically changing image in Linked IN using meta tag og:image is not working - linkedin

Below is Our Requirement:
Sharing the dynamically changing content of a page in Linked IN (URL, title, summary and image).
Problem Statement:
1. All other content except Image is getting shared in Linked IN
Approach 1: Using Linked In Share URL
<a target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&url=<<OUR URL>>&title=<<Our TITLE>>&summary=<<OUR SUMMARY>>">Share</a>
Issue:
1. The URL above doesn’t have the parameter to pass the image like title, summary etc.It is fetching the image from meta tag content which is having the property as “og:image” in the page
<meta property="og:image" content="<<IMAGE URL>>">enter code here
Since the image is changed dynamically in the page, we tried dynamically changing the content of this meta tag using jQuery. But when the new share window is opened it is trying to fetch the default image available in meta tag and not the one set using jQuery.
Approach 2: Using AJAX Post Submit Action
function shareOnLinkedInTest() {
var dataJson= {"share": {
"comment": "Posting from the API using XML",
"content": {
"title": "A title for your share",
"submitted-url": "http://developer.linkedin.com",
"submitted-image-url":
"ImageURL",
},
"visibility": { "code": "anyone" }
}};
$.ajax({
type: 'POST',
crossDomain : true,
contentType: "application/json",
dataType:"jsonp",
jsonp: 'jsonp-callback',
url: "https://api.linkedin.com/v1/people/~/shares?format=json",
data:dataJson,
success: function(data) {
alert("it works>>>>>>>>>>>>>>"+data);
},
error : function (xhr, ajaxOptions, thrownError){
alert("error");
console.log(xhr);
console.log(thrownError);
}
}); }
Issue:
This is throwing 401 –Unauthorized exception as there is no option to enter the user credentials in the above script while sharing the content
It has been observed while going through various reference sites that Linked In is having cache issue while sharing the content.
https://www.wix.com/support/html5/ugc/e828aa26-d50b-4e5a-a982-ff563ca7e3dd/061f3e24-55e1-418d-ab65-9d6b0457b863
Getting old image while sharing page in LinkedIn
Can anyone help on this please????
Thanks In Advance,
Saritha

LinkedIn's crawler does not execute in-page Javascript, so if you are relying on client-side code to set the value of the meta tags, it will not be picked up when LinkedIn grabs the page for sharing. The value has to be rendered into the page statically (and if it has to be a dynamic value, that would have to be chosen at the back-end and rendered into the page).
Regarding your second approach, you have to authenticate a user before you attempt to post a share, which is why you're getting a 401 Unauthorized error when you try. There's more information about making an authenticated REST API call available at https://developer.linkedin.com/docs/rest-api

Related

sending ajax request to a module service without no ajaxController

I want to count how many times my menu items are clicked. for this task, I have a visited cell in my menu table that is retrieved by some models. the menu items are shown on my layout.phtml each specified by their id and I am trying to use ajax for this matter as below:
### menu items in layout.phtml
<li>about</li>
### ajax code
$(document).ready(function(){
$('a#menuItems').click(function () {
var data={};
data.id =$(this).attr("data_id");
$.ajax({
type : 'POST',
url :'../../../module/Application/src/Model/visitCounter.php',
data :data,
success: function(data){
},
error:function(){
}
});
});
});
the visitCounter.php is a service model that gets the variables via POST method do the rest of the work but the problem is how to send this ajax request to the service model page. I wonder if there is a way to achieve that without any controller.
I really appreciate if anyone could help me with this.

Stripe payment with JMSPaymentBundle "The source parameter is required"

I already integrated JMSPaymentBundle, with paypal every thing works fine!
When I tried to change with stripe from this link for JMS
and using ruudk/PaymentStripeBundle from github, it's actually the same.
But there is a thing. I'm receiving this error: The source parameter is required
In the issues of the bundle, I found that I must use stripe form
<form action=""
method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="MYPUBLISHEDKEY"
data-amount="999"
data-name="Demo Site"
data-description="Widget"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto">
</script>
</form>
This form generates a Token. What I need to know is :
1- Where to put that published token used by JMSPaymentBundle?
2- What action in the form should I do? Is it the same for paypal?
it's hard to say what's going on here but it seems like https://github.com/ruudk/PaymentStripeBundle/ is lacking some necessary documentation.
From what I can tell it's adding a token hidden field to your forms:
https://github.com/ruudk/PaymentStripeBundle/blob/master/src/Form/CheckoutType.php#L12
However, the Checkout embed code you're using won't save the token to that field. I don't see any additional Javascript embedded in this library, so you'll need to build your own using the custom Stripe Checkout integration:
https://stripe.com/docs/checkout#integration-custom
Something like this should work:
var handler = StripeCheckout.configure({
key: 'pk_test_6pRNASCoBOKtIshFeQd4XMUh',
image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
locale: 'auto',
token: function(token) {
// NOTE: assuming that the field injected by the library has an ID of "token"--you'll have to check your DOM and possibly adjust this
var field = document.getElementById('token');
field.value = token.id;
// TODO: submit form and send to your backend
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// Open Checkout with further options:
handler.open({
name: 'Stripe.com',
description: '2 widgets',
zipCode: true,
amount: 2000
});
e.preventDefault();
});
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
handler.close();
});

How to disable automatic appending X-Requested-With=XMLHttpRequest into uri?

I use Ajax.BeginForm.. It loads me partial view. This view have links. After view is loaded via ajax each link has href that ends with X-Requested-With=XMLHttpRequest.
How can I disable automatic appending this parameter to my links?
This header is sent by jQuery everytime you perform an AJAX request. You could try disabling it by globally subscribing to the ajaxSend handler and overriding its value:
$(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
jqXHR.setRequestHeader('X-Requested-With', {
toString: function() { return ''; }
});
});
Notice that this will only set the value of the header to an empty string. It won't remove it from the request. A bug has been filed in jQuery asking to have the possibility to completely remove this request header and apparently it was rejected as not a bug.

Share activity on Google Plus using asp dotnet

How can i post an interactive post on google+ stream?
I am trying to post some custom data on google stream from asp.net web application.
This is the code iam using.
this is .aspx page:
Tell your friends
this is the script i am using:
var moment = {
"name": "sample",
"Description": "Hi sample post",
"Thumbnail": "logo",
"image": "http://prayati.com/Images/PrayatiLogo.jpg"
};
gapi.auth.init(signinCallback);
function signinCallback(authResult) {
if (authResult['access_token']) {
gapi.interactivepost.render('inter', options);
//gapi.interactivepost.render(moment, authResult['access_token'])
gapi.interactivepost.go(moment)
document.getElementById('myBtn').setAttribute('style', 'display: none');
} else if (authResult['error']) {
alert(authResult['error']);
}
}
var options = {
contenturl: 'https://plus.google.com/pages/',
contentdeeplinkid: '/pages',
clientid: '263087742134.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
prefilltext: 'Create your Google+ Page too!',
calltoactionlabel: 'SHARE',
calltoactionurl: 'http://plus.google.com/pages/create',
calltoactiondeeplinkid: '/pages/create'
};
The first and probably most important problem is that you have a domain mismatch between your data-calltoactionurl and your data-contenturl. These must be the same domain, see the data-contenturl documentation.
I believe that is your major problem, there are other problems in your example too:
You appear to be confusing two different features: app activities (aka moments) and interactive posts. Also, it looks like you are trying to do authentication, the interactive post button is also a sign-in button, notice its data-callback parameter. You wouldn't need to do a separate call to gapi.auth.init()
The most simple approach is to use the HTML button and remove the calls to gapi.interactivepost.* unless you have a dynamic application that needs to insert buttons with great control.
You didn't post the code for your JavaScript API include, ensure that it is loading the API script as https://apis.google.com/js/client:plusone.js.
Here is a correct and simplified button:
<button class="g-interactivepost"
data-clientid="xxxxxxxxxx.apps.googleusercontent.com"
data-contenturl="http://localhost:52022/Jaswanth"
data-cookiepolicy="single_host_origin"
data-calltoactionlabel="INVITE"
data-calltoactionurl="http://localhost:52022/create"
data-prefilltext="Best site EVER!"
data-callback="signinCallback"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login">
Tell your friends
</button>

What Facebook API call results in this? The result shows a publish dialog

I've asked this before, but in a different way, so I'm hoping asking it like this could get an answer :)
What API call results in this following dialog appearing:
http://dl.dropbox.com/u/222489/publishdialog.png
By using the FB.ui({method: 'stream.publish' ... function all I get is a "Post to Your Wall" dialog, and all great Facebook games get the dialog in the screenshot. So I must be using the wrong function.
I don't understand how you've missed it, it's the first snippet of code in the FB.ui documentation:
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
Result in my test app:
Its known as a Feed Dialogue.. its one of the Three Facebook Dialogues that use user interaction for doing some work...
ItI dosent need a API call (It was possible with Facebook.showFeedDialog but now facebook dosent support it) instead u redirect the user to the Url for these dialogues.
http://www.facebook.com/dialog/feed?<your different attributes as quesry string>
For having this in your own page you Can open it in an iFrameby setting attribute display=iframe but you need an access token for that..
Here is a complete description..
http://developers.facebook.com/docs/reference/dialogs/feed/

Resources