Using Linkedin API to see new connections of my 1st degree connections - linkedin

Is it possible to use the Linkedin API to see new connections made by my (authenticated user) 1st degree connections?
Using a call like:
GET http://api.linkedin.com/v1/people-search?facet=network,S
I can search for second degree connections. However, the goal is to get new connections of selected 1st degree connections.
Any help much appreciated.

You can get new connection with using this URL
http://api.linkedin.com/v1/people/~/connections?modified=new&modified-since=1267401600000
Where modified-since is the time you last made the request.
you can check more detail here https://developer.linkedin.com/documents/connections-api
I think Linkedin Change URL : New URL is :
https://developer-programs.linkedin.com/documents/connections-api

Yes. It's quite easy to see other people or your connections using the following code I wrote. If you want to search for other people's new connection, simply replace the 'Me' with other people's id.
//Function that displays the member's updates:
function onLinkedInAuth() {
IN.API.MemberUpdates("me")
.params({"type": "CONN", "count": 1}) // get the five most-recent Shares for the viewer and EjDUWNoC3C
.result(displayNetworkUpdates)
.error(displayNetworkUpdatesError);
}
//Note: You can only see your friend's most recent connection
function displayNetworkUpdates(updates) {
var profileDiv = document.getElementById("networkupdates");
var conns = updates.values[0].updateContent.person.connections; // the person sharing content
var man = conns.values[0];
profileDiv.innerHTML += "<p>" + man.firstName + " " + man.lastName +".</p>";
}
See when I look for people/my new connection, I only ask for 1. This is because LinkedIn API is not generous enough to grant more privilege. They ONLY ALLOW US TO VIEW 1 CONNECTION/ most recent connection.
Also, just so you know, find your friend's id is quite easy as well. Just search for connections of yours using the following code, then you can obtain a list of your connections and their IDs.
//Functions that displays users' connections
function onLinkedInAuth() {
IN.API.Connections("me")
.fields("firstName", "lastName", "industry", "id")
.params({"start": 10, "count": 5}) // start begins at 0
.result(displayConnections)
.error(displayConnectionsErrors);
}
function displayConnections(connections) {
var connectionsDiv = document.getElementById("connections");
var start = connections._start + 1; // because humans count from 1, not 0.
var range = connections._start + connections._count;
connectionsDiv.innerHTML = "<p>Displaying " + start + "-" + range + " of " + connections._total + " connections.</p>";
var members = connections.values; // The list of members you are connected to
for (var member in members) {
connectionsDiv.innerHTML += "<p>" + members[member].firstName + " " + members[member].lastName
+ " works in the " + members[member].industry + " industry"+ " ID: " + members[member].id ;
}
}
And if you want to see a list of new connections of your friend, I have one approach but haven't attempted yet. You can query LinkedIn database once/sec, and keep tracking of who is adding new connection. This is far beyond 100% accurate, but at least it gives you a list of connections.
Again, LinkedIn says you cannot store any information you obtained through API. That approach might be bad. If you query the server once/sec, probably your IP will be blocked as well.... so .... I conclude LinkedIn API is very limited.

Related

Performing transactions of fanned-out data in Firebase

I am working on creating a social network-esque feed, and have been following the guide on the Firebase blog on fanning out my "blog posts" across the database.
This makes sense and works well for interacting with these posts using the update() method. However, it is unclear to me how I could go about performing transactions atomically in multiple places.
For example, I want to add the ability to 'like' a post. If I were to have that post in one location, my code would look like so:
var postRef = firebaseDB.ref("posts/" + postID + "/likes");
postRef.transaction(function(likes) {
return (likes || 0) + 1;
});
For obvious reasons, the solution below is not atomic.
var postRef1 = firebaseDB.ref("posts/" + postID + "/likes");
postRef1.transaction(function(likes) {
return (likes || 0) + 1;
});
var postRef2 = firebaseDB.ref("user/" + userID + "/posts/" + postID + "/likes");
postRef2.transaction(function(likes) {
return (likes || 0) + 1;
});
Since transaction operates on a ref, how can I "like" the posts in multiple places atomically?
For your usecase, you need firebase-queue with throttle on the client when writing to the queue task's node.
Your fan out occurs in the worker node where you can build the compensation model based on promise success/failure.
queue is the only way to guarantee the work is completed and simplifies your client code.
Reference: ways to live without transactions
=========
Edit: March 2017 Cloud functions for Firebase was introduced and is now the recommended way to implement fan-out.

Asynchronous with indexeddb problems

I am having problem with a function in IndexedDB, where I need to change the status of some meetings. The Search feature which meetings are checked by grabbing the ID of each one of them, soon after I A for() where I retrace the vector that contains the ids for each database access do I get a different passing the id of the time. The following code example:
var val = [];
var checkbox = $('input:checkbox[class^=checkReunioes]:checked');
if(checkbox.length > 0){
checkbox.each(function(){
val.push($(this).val());
});
}
for(var i = 0; i < val.length; i++){
var transaction = db.transaction(["tbl_REUNIOES"], "readwrite").objectStore("tbl_REUNIOES");
var request = transaction.get(val[i]);
request.onerror = function(event) {
alert("BAD");
};
request.onsuccess = function(event) {
var data = request.result;
data.FLG_STATU_REUNI = 'I';
var codigo_igreja = localStorage.getItem("igreja");
var dataJSON = JSON.stringify(data);
enviarFilaSincronismo("tbl_REUNIOES", "U", dataJSON, " WHERE COD_IDENT_REUNI = '" + val[i] + "' and COD_IDENT_IGREJ = '" + codigo_igreja + "'");
var requestUpdate = transaction.put(data);
requestUpdate.onerror = function(event) {
alert("OK");
};
requestUpdate.onsuccess = function(event) {
$("#listReunioes").html("");
serchAll(w_key_celula);
};
};
}
In my view the problem is occurring due to be a bank indexeddb asynchronous, it passes to the next search, even before the first stop.
But how can I do to confer this ?
What is the good practice for something in this case ?.
If you are inexperienced with writing asynchronous code, a good general rule to consider is to never define functions inside loops. Do not set request.onsuccess to a function from within the for loop.
You can perform multiple get and put requests on the same transaction when you do not expect the individual requests to fail for data-related reasons, such as the violation of a uniqueness constraint of an index, or because you are performing many thousands of requests on the same transaction and reaching processing limits.
You might find that using IDBObjectStore.prototype.openCursor together with IDBCursor.prototype.update is more convenient than using IDBObjectStore.prototype.get and IDBObjectStore.prototype.put.
Your example code indicates that a successful get request means that data was retrieved, when in fact, this is not what actually happens. A successful get request just means that a request occurred without errors (e.g. against an object store that exists, against a database that is not blocked by other requests, against a database connection that is still valid). It does not mean that an object matched your get request query. You should be checking for whether the request's result object is defined, and use that check as a determination of whether an object matched your get query, and not simply that a successful request occurred.
You might want to spend more time organizing your code into smaller functions that use clearer names. Your example code is difficult to read.
It looks like you are using some type of global db variable. If you are not well experienced with writing asynchronous code, avoid using a global db variable. There is no guarantee the db variable will be defined and open when you decide to access it, which could lead to an unexpected error.

Google forms scripts to send email

I have created a script to go along with a camp signup form. When I student signs up, I need an email sent to both the parent and the leader. I have the general script format correct as each one works when by itself (the script is bound to the spreadsheet, not the form). But if I have both functions in the code.gs file or in a separate file, neither of them work. How are we supposed to run more than one function attached to a form submission?
Here is my code for the two emails to be sent:
Here is my code for the two emails to be sent (if I add both these, it doesn't work):
function emailResponseToParent(e) {
var studentName = e.values[1];
var parentEmail = e.values[3];
var tripName = e.values[6]
var subject = "Your Young Life " + tripName + " registration has been submitted."
var message = "We have received " + studentName + "'s signup registration for the " + tripName + ". More words here....";
MailApp.sendEmail(parentEmail, subject, message);
}
function emailResponseToLeader(e) {
var studentName = e.values[1];
var leaderEmail = "meg#me.com";
var tripName = e.values[6]
var subject = "A Young Life student of yours has signed up for " + tripName + " camp."
var message = studentName + "has just registered for " + tripName + ". More words here....";
MailApp.sendEmail(leaderEmail, subject, message);
}
A separate question (less important) is how to create a script so that a later follow up email goes out based on a date (e.g. the week before camp starts).
I don't know if this will be of any use but you can create a list of recipients to receive the SAME email (just like any email can specify multiple recipients). To do this replace your MailApp with the following:
var Emails = parentEmail + "," + leaderEmail;
MailApp.sendEmail(Emails, subject, message);
It has worked for me (but both recipients wanted the same info).
I couldn't get my script to access the form data until I came across the method used in your script (e.values[ ] ) which worked a treat - so thanks for that!

Can a Google Apps Script Web App using UiService be tracked with Google Analytics?

Is there any possibility to to insert a working Google Analytics tracker into a web app using UiApp as user interface?
This would provide the app owner with in depth usage statistics.
The only possible alternative i can think of, storing every access to the web app including user's Id in the ScriptDb, is problematic from the data privacy point and doesn't provide the essential informations about the user like location, language or device.
Yes it's totally doable and I have an internal library for this. The concept is you Urlfetch a gif from the google analytics server and pass data via the querystring. Here's working code and a test. Google Analytics docs references are inline :
Edit: I have packaged the below as a Library called GASAnalytics and added the project key "MvzvykyEXRZJoG1Gjj2h1JnHAGDwXQ1CH" to the More Google Apps Script Libraries list here: https://docs.google.com/spreadsheet/ccc?key=0AhDqyd_bUCmvdGxjNUpGZkFKcmxsekE3VHNWMEh4amc#gid=0
/**
* hits Google Analytics with a "path" you want to track as a pageview
* e.g. track("UA-ABC123-4", "/track/my/event")
*/
function track(propertyId, path) {
//ref https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting#gifParameters
//https://developers.google.com/analytics/devguides/collection/other/mobileWebsites
var utmGifLocation = "http://www.google-analytics.com/__utm.gif";
// Construct the gif hit url.
var utmUrl = utmGifLocation + "?" +
"utmwv=4.4sa" +
//"&utmcn=1"+ //added - extra - not required
"&utmn=" + (new Date().getTime())+ //unique - cache buster
"&utmhn=" + 'example.com' +
"&utmr=" + '-' +
"&utmp=" + encodeURIComponent(path) +
"&utmac=" + propertyId +
"&utmcc=__utma%3D999.999.999.999.999.1%3B" +
"&utmvid=" + Math.random() +
"&utmip=" + '-';
Logger.log("Fetching " + utmUrl);
var test = UrlFetchApp.fetch(utmUrl);
return;
}
function testTrack() {
// confirm in GA > Realtime (immediate) or Standard Reports > Content > Content drilldown (after 2 hours)
track("UA-heyuseyourown:/!", "/track1/my1/test1");
}
Let us know how you go.

Meteor multiplayer game clients get out of sync - how to debug?

I've built a simple real-time multiplayer math game in Meteor that you can try out here: http://mathplay.meteor.com
When playing locally (using different browsers), everything works fine. But when I play over the Internet with friends, the clients often get out of sync: a question listed as active for one player is actually already solved by another player.
My guess is that some code that should be server-only gets executed on one of the clients instead. Any suggestions on how to debug this behavior?
Here is what happens on the client when user submits an answer:
Template.number_input.events[okcancel_events('#answertextbox')] = make_okcancel_handler({
ok: function (text, event) {
question = Questions.findOne({ order_number: Session.get("current_question_order_number") });
if (question.answer == document.getElementById('answertextbox').value) {
console.log('True');
Questions.update(question._id, {$set: {text: question.text.substr(0, question.text.length - 1) + question.answer, player: Session.get("player_name")}});
callGetNewQuestion();
}
else {
console.log('False');
}
document.getElementById('answertextbox').value = "";
document.getElementById('answertextbox').focus();
}
});
callGetNewQuestion() triggers this on both client and server:
getNewQuestion: function () {
var nr1 = Math.round(Math.random() * 100);
var nr2 = Math.round(Math.random() * 100);
question_string = nr1 + " + " + nr2 + " = ?";
question_answer = (nr1 + nr2);
current_order_number = Questions.find({}).count() + 1;
current_question_id = Questions.insert({ order_number: current_order_number, text: question_string, answer: question_answer });
return Questions.findOne({_id: current_question_id});//current_question_id;
},
Full source code is here for reference: https://github.com/tomsoderlund/MathPlay
Your problem lies with this:
callGetNewQuestion() triggers this on both client and server
This will generate a different _id because of the timing difference, as well as a different question which will then get replaced with that one that the server generated. However, this might not always be the case. This makes it very easy to let things get out of sync, simply because your client is generating its own stuff.
You'll need to figure out a better approach at making sure the client generates the same data as the server. Which can be done by making sure that a random number generator is seeded the same way and thus would give the same random numbers every time. This will resolve any flickering because the values are different.
Then, for the actual bug you might not want to do this:
return Questions.findOne({_id: current_question_id});
But do this instead (only on the client, do nothing on the server):
Session.set('current_order', current_order_number); // ORDER! Not the _id / question_id.
That way, you can put the following in a template helper:
return Questions.findOne({ order_number: Session.get('current_order') });
In essence, this will work in a reactive way on the Collection and not dependent on the return value.

Resources