Share activity on Google Plus using asp dotnet - asp.net

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>

Related

Deep Link doesn't open the app instead does a google search

I have been using Expo to develop a react-native app, The functionality I am currently trying to implement is to share a link with friends on platforms such as fb messenger/whatapp or even normal texts and when they click this link it will launch my app to a specific page using the parameters.
After extensive research online - I’ve come to a blocker, following expo’s documentation I defined a scheme for my app - when I press share everything works correctly a message is created and I’m able to share content but only as string.
I am using react-natives Share library to share to an app and I’m using Expo to provide me with the link.
Ideally my first goal is to get the app opening using the Expo Link before I explore further into adding more functionality to the link.
Share.share({
message: "Click Here to View More! " + Linking.makeUrl( ' ' , { postkey : "7a5d6w2x9d6s3a28d8d});
url: Linking.makeUrl( ' ' , { pkey : gkey });
title: 'This post is amazing',
})
.then((result) =>{
console.log(result)
if(result === 'dismissedAction'){
return
}
})
.catch((error) => console.log(error))
In the root of my app I have also defined the event handlers: App.js
_handleRedirect=(event)=> {
let {path,queryParams} = Linking.parse(event);
Alert.alert(`queryparams : ${event} path : ${path} `)
this.props.navigation.navigate("Post_Detail",{key:queryParams.postkey})
}
}
componentDidMount() {
let scheme = 'nxet'
Linking.getInitialURL()
.then(url => {
console.log("App.js getInitialURL Triggered")
// this.handleOpenURL({ url });
})
.catch(error => console.error(error));
Linking.addEventListener('url', ({url}) => this._handleRedirect(url));;
}
componentWillUnmount() {
Linking.removeEventListener('url', this.handleOpenURL);
}
When I share the link to Whatsapp, Facebook Messenger or even just messages or notes it appears as myapplink://, I try to enter this into the browser and instead of asking me to open my app - it does a google search.
Please note I am attempting to have this working on Android Device and facing this issue
Is there something I am doing incorrectly?
Any help is much appreciated. Thanks.
You can not open external links, means other than http, https on Android. But you can on iOS. In order to be able to open your expo links, you need proper anchor tags on android. You can create html mails and give it a try, you will see it is gonna work on Android as well.

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

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

How to check if users shared info on wall?

What i need to do is when user login to game and share our adv picture i want check is share successful and add extra XP points. So i created link like this:
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=Title of sharer;&p[summary]=Descriobe abiut game etc&p[url]=http://google.com&&p[images][0]=http://www.some.jpg','sharer','toolbar=0,status=0,width=548,height=455');" href="javascript: void;">
test </a>
So do i have no respond implementation. DO i need create some APP in fb and do by API with my APP ID or how to resolve this problem ?
You can use the Facebook JavaScript SDK to track if the user successfully shared something to their wall. This tutorial shows how to achieve this.
If you share something to the wall using the FB.ui dialog box, you can add a callback to the function to track success / failure, as follows:
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
if ( response !== null && typeof response.post_id !== 'undefined' ) {
console.log( response );
// ajax call to save response
$.post( '{url_that_will_track_share}', { 'meta': response }, function( result ) {
console.log( result );
}, 'json' );
}
} );
In this example, the callback triggers an ajax call to another page with the response from the Feed dialog. If the user shared the post, the response will contain the post_id. You can use the ajax script to check if the post_id exists and is valid and then award XP points accordingly.

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/

Tokenizing autocomplete jquery plugin not working with ASP.NET MVC

I am using the autocomplete plugin but for some reason it is not getting to the controller when I start typing in the text box.
Has anyone used this? or worked with this? or got a working example? I've tried changing the url to /Referral/Get but still does not work
$("#uxSearch").tokenInput("../Referral/Get",
{
hintText: "Type in something",
noResultsText: "No Results",
searchingText: "Searching",
classes: {
tokenList: "token-input-list-facebook",
token: "token-input-token-facebook",
tokenDelete: "token-input-delete-token-facebook",
selectedToken: "token-input-selected-token-facebook",
highlightedToken: "token-input-highlighted-token-facebook",
dropdown: "token-input-dropdown-facebook",
dropdownItem: "token-input-dropdown-item-facebook",
dropdownItem2: "token-input-dropdown-item2-facebook",
selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
inputToken: "token-input-input-token-facebook"
}
});
You might show us your global.asax.cs routes. Avoid using ../ in relative URLs with ASP.NET MVC. Rather use it like this with a helper method:
$("#Products").focus().autocomplete('<%=Url.Action("GetProducts", "Product") %>', { ...
(the above is from my autocomplete request)
As Zhaph said, try browsing to the URL manually through browser to see if controller actions work fine.

Resources