我正尝试使用LinkedIn在我的网站上为用户提供的名字和电子邮件地址。这是我做了什么:无法使用LinkedIn授权
在我的LinkedIn应用程序,我设置的默认范围(OAuth的用户协议)来:
- r_basicprofile
- r_contactinfo
- w_share
- r_emailaddress
我已将我的网域正确添加到JavaScript API域。我没有添加到OAuth 2.0重定向网址的链接。但我不知道这是否是强制性的(以及要插入哪条路径)?
我也复制我的API密钥(消费者密钥)。
现在在我的HTML我有:
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
lang: en_US
api_key: myapikey
scope: r_basicprofile r_emailaddress
</script>
<input class="apply-with-linkedin" type="button" value="Apply with LinkedIn" id="btn-linkedin-apply">
<script type="text/javascript">
jQuery('#btn-linkedin-apply').click(function (e) {
e.preventDefault();
e.stopPropagation();
IN.User.authorize(function()
{
IN.API.Profile('me').fields([
'firstName',
'lastName',
'emailAddress'
]).result(function (profiles)
{
var me = profiles.values[0];
if (me.hasOwnProperty('firstName')) {
jQuery('#apply-form #input-firstname').val(me.firstName);
}
if (me.hasOwnProperty('lastName')) {
jQuery('#apply-form #input-lastname').val(me.lastName);
}
if (me.hasOwnProperty('emailAddress')) {
jQuery('#apply-form #input-email').val(me.emailAddress);
}
});
});
});
</script>
但是,当我按一下按钮我总是得到JavaScript错误Cannot read property 'authorize' of undefined
。 IN.User
未定义。
这可能是什么问题? ...
UPDATE:
的JavaScript代码,我指定我的API密钥,......我从"Getting Started with the JavaScript SDK" from LinkedIn复制。
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [API_KEY]
onLoad: [ONLOAD]
authorize: [AUTHORIZE]
lang: [LANG_LOCALE]
</script>
'郎咸平:EN_US API_KEY:myapikey范围:r_basicprofile r_emailaddress'是远不有效的JavaScript。 – 2015-03-02 08:25:14
@JeremyThille:我为我的主题添加了更新。你可以看一下吗? – nielsv 2015-03-02 08:31:43
是的,这就是我说的:这绝对不是Javascript。在我看来,你甚至没有这门语言的基础知识。这些行不能运行,并且显然会导致错误。尝试先写一些Javascript。 – 2015-03-02 08:33:42