我是第一次创建网站。我很抱歉任何愚蠢的问题,但我真的没有背景。但是,我正在努力学习。 我在Weebly(www.i2i.network)上开发了这个网站,我试图通过他们的API服务包含一个LinkedIn SignUp按钮来监控使用该网站的人。
到目前为止,我复制并粘贴了我在LinkedIn SDK指南中找到的内容
<script type="in/Login"></script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
IN.User.logout(callbackFunction, callbackScope);
api_key: [API] //I put my API key here
authorize: true
onLoad: onLinkedInLoad
lang: [LANG_LOCALE]
</script>
<script type="text/javascript">
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Handle the successful return from the API call
function onSuccess(data) {
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
IN.API.Raw("/people/~").result(onSuccess).error(onError);
}
</script>
该按钮第一次出现,它打开了与我的LinkedIn个人资料的连接。真令人兴奋! :D(Geek)
此时我仍然不知道我是否从LinkedIn API服务中检索任何数据以及是否&#34;是&#34;如何管理它们并可能将它们包含在Intercom.io中。
据我所知,我应该从LinkedIn API收到以下内容:
{
"firstName": "Frodo",
"headline": "Jewelery Repossession in Middle Earth",
"id": "1R2RtA",
"lastName": "Baggins",
"siteStandardProfileRequest": {
"url": "https://www.linkedin.com/profile/view?id=…"
}
}
我真的收到了答案吗?我该怎么看?如何在以下Intercom.io脚本中使用它?
<script>
window.intercomSettings = {
app_id: "k9sz4pfb",
name: "Nikola Tesla", // Full name
email: "nikola@example.com", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/k92zopfb';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
我知道这可能是一个非常基本的问题,但我从零开始,我喜欢通过练习来学习......
此外,如果您对网站或教程有任何建议,我可以逐步学习,我们将非常感激。
感谢您的帮助,
贾科莫
答案 0 :(得分:0)
仔细检查语法,但这应该让你开始。
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
var dataOutput =
// I added the callback event DONE. This assures the data method is called when the this API call is successful and complete.
var dataOutput = IN.API.Raw("/people/~").result(onSuccess).error(onError).done( {
if (dataOutput != null) {
DoSomethingWithYourData(dataOutput);
}
});
}
function DoSomethingWithYourData(dataOutput) {
console.log(dataOutput);
// Parse your data or assign it to a control. do whatever here.
}
要回答你的另一个问题,你可以将它添加到JS脚本文件并在其他页面上引用它,但你必须保持添加到这个脚本文件的任何控件ID /类名相同,所以我的提示将保持这个文件非常通用,以便它不依赖于其他任何东西,只处理使用LinkedIn的数据。
我建议您使用这些链接进行进一步阅读,以便扩展您的代码。