I am trying to implement login with linked in my web app. Here is my code..
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 'key here'
</script>
</head>
<body>
<script>
IN.User.authorize(function (e) {
console.log(e);
}, function (e) {
console.log(e);
});
</script>
</body>
But its giving me error 'Cannot read property 'then' of undefined at Object.authorize (in.js:18)'
i have also tried this way..
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 'key here'
onLoad: 'onLinkedInLoad'
authorize: true
</script>
</head>
<body>
<!-- LinkedIn signin button -->
<script type="in/Login"></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);
}
</script>
</body>
but its giving me errror
'in.js:7 Uncaught (in promise) TypeError: Could not instantiate tag for 'login': Cannot read property 'on' of null
at new (Login.js?version=0.1.149:7)
at in.js:18'
The documentation and examples for linkedIn show api_key and onLoad function not being set as a string delimeter.
api_key: 0192afsdj10
onLoad: onLinkedInLoad
Secondly, you have not added in a function for the getProfileData function.
Here is an example of the should look like.
function getProfileData() {
IN.API.Profile("me").fields("id", "first-name", "last-name", "headline", "location", "picture-url", "public-profile-url", "email-address").result(displayProfileData);
}
function displayProfileData(profiles){
var member = profiles.values[0];
console.log(member);
}
See code referenced here
Related
I would like to know how to use google analytics event code in lit-element,
When try to debug, getting the error as Command ignored. Unknown target: undefined and Referance Error: ga not defined.
I have implemented event tracking in the component, but its not working getting the following error,
//index.ejs
<!doctype html>
<html>
<head>
<script src="/node_modules/#webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
<script src="/node_modules/#webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<title>LitElement Example</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXX-X"></script>
</head>
<body>
<service></service>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', "UA-XXXX-X");
</script>
</body>
</html>
//lit-component.js
import { LitElement, html, css } from 'https://cdn.pika.dev/lit-element';
export class Services extends LitElement {
constructor() {
super();
}
handleGA(e){
ga('click', 'event', {
eventCategory: 'site',
eventAction: 'click',
eventLabel: e.target.id
});
}
render(){
<p>Welcome To My Site</p>
<button class="btn btn-primary" id="service" #click=${(e)=>this.hanldeGA(e)}>Click Here</button>
}
}
customElements.define('service', Services);
This is my logout script for linked in account. But its logged out only my site login details not logged out opened linkedin account. Can you anybody find my issue?
<button onclick="javascript:onLoad();">Logout In LinkedIn</button>
Script:
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: mykey
authorize: true
onLoad: onLoad
</script>
<script type="text/javascript">
function onLoad() {
try {
IN.User.logout();
} catch (err) {
console.log(err);
}
setTimeout("goToHome()", 100);
}
function goToHome() {
document.location.href = "https://www.linkedin.com/secure/login?session_full_logout=&trk=hb_signout";
location.href="logout";
}
</script>
This is my first React code. I am trying to call a Restful web services from React.
It kept saying "Uncaught TypeError: this.setState is not a function". I couldn't figure out what's wrong with the code.
<!DOCTYPE html>
<html>
<head>
<title>React Flux</title>
<script src="https://fb.me/react-0.13.3.js"></script>
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<div id="component"></div>
<script type="text/jsx">
var JavaEEWSTest = React.createClass({
getInitialState: function () {
return {text: ''};
},
componentDidMount: function(){
$.ajax({
url: "http://localhost:8080/rest/user/456"
}).then(function(data) {
this.setState({text: data.name});
}).bind(this)
},
render: function() {
return <div>Response - {this.state.text}</div>;
}
});
React.render(<JavaEEWSTest />, document.getElementById('component'));
</script>
</body>
</html>
You need set this to callback function
$.ajax({
url: "http://localhost:8080/rest/user/456"
}).then(function(data) {
this.setState({text: data.name});
}.bind(this))
^^^^^^^^^^^
but not for $.ajax/then - }).bind(this)
I am trying to use the JSONForm libary from Github to generate a html markup from a json schema. I am trying to do this in an MVC view that does not have a default form tag. I added one with html.beginform but still the markup is not generated and i get the following javascript error in console :TypeError: _ is null . Could someone help me out ?
Below is the code in the view :
#{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
#using (Html.BeginForm())
{
<script type="text/javascript" src="~/Scripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="~/Scripts/json-form.js"></script>
<script type="text/javascript" src="~/Scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="~/Scripts/underscore.js"></script>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<script type="text/javascript">
$('form').jsonForm({
schema: {
name: {
type: 'string',
title: 'Name',
required: true
},
age: {
type: 'number',
title: 'Age'
}
},
onSubmit: function (errors, values) {
if (errors) {
}
else {
}
}
})
$(document).ready(function () {
alert('udayan');
});
</script>
<h2>Index</h2>
}
json-form.js depends upon underscore (_). You therefore need to move:
<script type="text/javascript" src="~/Scripts/underscore.js"></script>
... so that it is above:
<script type="text/javascript" src="~/Scripts/json-form.js"></script>
I tried using emailjs browserbox to connect to an imap server but the sample script with the correct port and host and username and password just throws out errors and doesn't work in a client-side html file?
https://github.com/whiteout-io/browserbox is a link to the api. What's wrong with how I wrote the code?
<html>
<head>
<title>Test</title>
<!-- Required for non-Unicode encodings -->
<script src="encoding-indexes.js"></script>
<script src="encoding.js"></script>
<script src="stringencoding.min.js"></script>
<script src="browserbox.js"></script>
<script src="browserbox-imap.js"></script>
<script> var client = new BrowserBox('host', port, {
auth: {
user: 'testuser',
pass: 'testpass'
},
id: {
name: 'My Client',
version: '0.1'
} });
</script>
</head>
<body>
</body>
</html>