Linkedin Direct Message Example
Linkedin Direct Message Example
When logged in user, and provides functionality for sending messages to the connected user .
Open your linkedin see your message like bellow picture
You can download the code here
When logged in user, and provides functionality for sending messages to the connected user .
Open your linkedin see your message like bellow picture
You can download the code here
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://platform.linkedin.com/in.js"> | |
api_key: ********** //Your API Key | |
onLoad: onLinkedInAuth | |
scope: r_network w_messages | |
authorize: false | |
</script> | |
<script type="text/javascript"> | |
function onLinkedInLoad() { | |
IN.Event.on(IN, "auth", onLinkedInAuth); | |
} | |
function onLinkedInAuth() { | |
var div = document.getElementById("sendMessageForm"); | |
div.innerHTML = '<h2>Send a Message To Yourself</h2>'; | |
div.innerHTML += '<form action="javascript:SendMessage();">' + | |
'<input id="message" size="30" value="You are awesome!" type="text">' + | |
'<input type="submit" value="Send Message!" /></form>'; | |
} | |
function SendMessage(keywords) { | |
var message = document.getElementById('message').value; | |
var BODY = { | |
"recipients": { | |
"values": [{ | |
"person": { | |
"_path": "/people/~", | |
} | |
}] | |
}, | |
"subject": "JSON POST from JSAPI", | |
"body": message | |
} | |
IN.API.Raw("/people/~/mailbox") | |
.method("POST") | |
.body(JSON.stringify(BODY)) | |
.result(displayMessageSent) | |
.error(function error(e) { alert ("No dice") }); | |
} | |
function displayMessageSent() { | |
var div = document.getElementById("sendMessageResult"); | |
div.innerHTML += "Yay!"; | |
} | |
</script> | |
</head> | |
<body> | |
<script type="IN/Login"></script> | |
<div id="sendMessageForm"></div> | |
<div id="sendMessageResult"></div> |