Topic-icon Retrieve/update of a member connections and post to them.

Active Subscriptions:

None
10 years 6 months ago - 10 years 6 months ago #37568 by Toni
I would like for each member who registred with linkedin or are logged in with Linkedin to:

- Retrieve his/her 1st level connections through the Linkedin's Connections API (developer.linkedin.com/documents/connections-api).
- Update his/her 1st level connections through the Linkedin's Get Network Updates API (developer.linkedin.com/documents/get-net...s-and-statistics-api).
- Post messages on his/her behalf to his/her 1st connections using the Post Network Update function of Linkedin (developer.linkedin.com/documents/post-network-update).

Is that possible to do it using Jlinked and, if yes, can you briefly explain how to proceed in order to let me figure if it is complicated or not ?
Last edit: 10 years 6 months ago by Toni.
The topic has been locked.
Active Subscriptions:

None
10 years 6 months ago - 10 years 6 months ago #37579 by Toni
I misplaced this thread: this is a pre-sales question...
Last edit: 10 years 6 months ago by Toni.
The topic has been locked.
Support Specialist
Toni,
I'll move this to the Pre-Sales form after I post, so look for it there.

Getting a user's connections isn't something we support directly right now. We are considering some integration to automatically make 'friends' in JomSocial and other Joomla extensions in the future though. To get a user's connections with that API is actually just a few lines of code you could implement like:
$profileLibrary = JLinkedProfileLibrary::getInstance();
$liUser = $profileLibrary->fetchProfile($liMemberId, array('connections'));
$connections = $liUser->get('connections');
From there, you'll have an array of their connections. I haven't tested that code directly, but it should just work. Beyond that, you'd need to store it in a database, write it to a file or do whatever you want with it.

- Update his/her 1st level connections through the Linkedin's Get Network Updates API

We don't support the Get Network Updates API currently and this would take some work to add.

- Post messages on his/her behalf to his/her 1st connections using the Post Network Update function of Linkedin

Posting a message, as above, is a few lines of code. However, you'd need to make sure you strictly adhere to LinkedIn's policies, specifically:

The user must be given a choice about whether to send the message. The user must opt into the messages being sent rather than opt out.

So, you can't just post on behalf of the user when joining your site or something else without them allowing/denying the message.

I hope that helps explain,
Alex
The topic has been locked.
Active Subscriptions:

None
10 years 6 months ago - 10 years 6 months ago #37725 by keroman
Hi Alex,

I had to subscribe your product with an other account. For this reason I am continuing this thread with an other username.

First of all, thanks for your answer.

I have several other question:

alzander wrote: To get a user's connections with that API is actually just a few lines of code you could implement like:

$profileLibrary = JLinkedProfileLibrary::getInstance();
$liUser = $profileLibrary->fetchProfile($liMemberId, array('connections'));
$connections = $liUser->get('connections');


where should these lines of code be included ?

I also need to record the facebook friends of a user when he register on the site. Which code has to be used to get an array of a user's friends and, again, where should I put it ?

alzander wrote:

- Post messages on his/her behalf to his/her 1st connections using the Post Network Update function of Linkedin

Posting a message, as above, is a few lines of code.


What I want to do is to post a message when submitting a form managed with the 'fabrik' component. With this extension, I can include some php code to be executed 'on form submit'.

Which code should I use to have access to JLinked library and to post a message using the 'Post Network Update' API ? (there is no developer doc such as the one of JFBConnect...)

alzander wrote: However, you'd need to make sure you strictly adhere to LinkedIn's policies, specifically:

The user must be given a choice about whether to send the message. The user must opt into the messages being sent rather than opt out.

So, you can't just post on behalf of the user when joining your site or something else without them allowing/denying the message.


I am aware of this. I will probably include an 'opt in' checkbox in my form and the code to post the message will only be executed if the box is checked.

alzander wrote:

- Update his/her 1st level connections through the Linkedin's Get Network Updates API

We don't support the Get Network Updates API currently and this would take some work to add.


Can you at least give me some guidelines on how to proceed.

best regards.
Last edit: 10 years 6 months ago by keroman.
The topic has been locked.
Active Subscriptions:

None
Friendly bump...
The topic has been locked.
Support Specialist
Apologies for the delay. Hopefully, the answers below get you going, but if not, let us know.

where should these lines of code be included ?

I also need to record the facebook friends of a user when he register on the site. Which code has to be used to get an array of a user's friends and, again, where should I put it ?

In JLinked, you can put that code in the /components/com_jlinked/controllers/loginregister.php file. In there, around line 195, you'll see:
$loginRegisterModel = $this->getModel('LoginRegister', 'JLinkedModel');
        $redirect = $loginRegisterModel->getLoginRedirect();
If you add the code directly after those lines, it will get executed on every login of a user from LinkedIn. Test the code, again, as mentioned, to make sure it works. Additionally, that will get the connections.. but you'll need to 'do' something with them (like store in a database or a file or wherever you want that data to go).

For Facebook, the code to get a user's connections is:
$fbUserId = JFBCFactory::provider('facebook')->getProviderUserId();
$connections = JFBCFactory::provider('facebook')->profile->fetchProfile($fbUserId, 'friends');
That will return an array of FB User Id's and names of the user's friends. You can add that to the /components/com_jfbconnect/controllers/login.php file around line 152, right after where you'll see:
$redirect = $loginRegisterModel->getLoginRedirect($provider);

Which code should I use to have access to JLinked library and to post a message using the 'Post Network Update' API ? (there is no developer doc such as the one of JFBConnect...)

There isn't an easy call to do just post to a user's update. You'd need to make a call like below:
$jlinkedLibrary = JLinkedApiLibrary::getInstance();
$return = $jlinkedLibrary->api('people', '~/person-activities:(activity=xyz,body=yyy');
I've never tested that, and you'll need to make sure you read over the document you posted above for more information on how to do that.

We don't support the Get Network Updates API currently and this would take some work to add.

Right now, I don't have any suggestions on this. You'd need to add an endpoint for LinkedIn to call and process those updates. It's not something I can just give a line of code for. We do have plans to support 'automatic updates' from both LinkedIn and Facebook in a future update, hopefully around the beginning of next year.

I hope that helps,
Alex
The topic has been locked.