采用asp DOTNET在谷歌加分享活动 [英] Share activity on Google Plus using asp dotnet
问题描述
如何上传到谷歌+流的互动讯息?
我想从asp.net web应用程序发布在谷歌流了一些自定义的数据。
这是code IAM使用。
这是.aspx页面中:
告诉你的朋友
这是我使用的脚本:
VAR时刻= {
名:样品,
说明:嗨样品邮报,
缩略图:标志,
形象:http://prayati.com/Images/PrayatiLogo.jpg
};
gapi.auth.init(signinCallback);
功能signinCallback(authResult){
如果(authResult ['ACCESS_TOKEN']){
gapi.interactivepost.render(INTER,选项);
//gapi.interactivepost.render(moment,authResult ['ACCESS_TOKEN'])
gapi.interactivepost.go(瞬间)
的document.getElementById('myBtn')的setAttribute('风格','显示:无')。
}否则如果(authResult ['错误']){
警报(authResult ['错误']);
}
}
VAR的选择= {
的contentURL:https://plus.google.com/pages/',
contentdeeplinkid:/页,
客户端ID:'263087742134.apps.googleusercontent.com',
的CookiePolicy:single_host_origin',
prefilltext:创建您的Google+专页呢!,
calltoactionlabel:分享,
calltoactionurl:http://plus.google.com/pages/create',
calltoactiondeeplinkid:/页/创建
};
第一个也可能是最重要的问题是,你有你的数据calltoactionurl之间的域名不匹配
和你的数据的contentURL
。这些都必须是同一个域,请参见 数据的contentURL
文档。
我相信,是你的大问题,也有你的例子太多其他问题:
您似乎混淆了两个不同的功能:应用程序活动(又名时刻)和交互式的职位。此外,它看起来像你正在尝试做认证,交互式按钮后也是一个登录按钮,注意它的数据回调
参数。你不会需要做一个单独调用 gapi.auth.init()
最简单的方法是使用HTML按钮和删除调用gapi.interactivepost *除非你有一个需要插入按钮以极大的控制动态应用程序。
您没有贴code为你的JavaScript API包括,确保它在加载API脚本 https://apis.google.com/js/client:plusone。 JS
。
下面是一个正确的和简化的按键:
<按钮类=G-interactivepost
数据的clientid =xxxxxxxxxx.apps.googleusercontent.com
数据的contentURL =HTTP://本地主机:52022 / Jaswanth
数据的CookiePolicy =single_host_origin
数据calltoactionlabel =邀请
数据calltoactionurl =HTTP://本地主机:52022 /制造
数据 - prefilltext =最佳现场EVER!
数据回调=signinCallback
数据requestvisibleactions =http://schemas.google.com/AddActivity
数据范围=https://www.googleapis.com/auth/plus.login>
告诉你的朋友
< /按钮>
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>
这篇关于采用asp DOTNET在谷歌加分享活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!