Following a company - Javascript API

8 posts / 0 new
Last post
- -
Joined: 2011-06-02
Sep 11, 2011
Following a company - Javascript API

Hi,

I am looking for a javascript api which will allow people to follow a company. In this page https://developer.linkedin.com/apis under companies section this api is listed - "IN.API.Raw("/people/~/following/companies")" but the links take me to https://developer.linkedin.com/documents/inapiraw where no instructions are listed for follow company api. It will be great help if someone provide any documentation. Thanks....

Kirsten Hunter's picture
Joined: 2011-06-30
Sep 12, 2011

You need to use the raw API to call the backend REST call. Documentation on the company follow API is here.

- -
Joined: 2011-06-02
Sep 14, 2011

Thanks for your reply, for using oath i need a server side language but I am trying to do it through javascript only, is it possible? If possible can you please help with some sample codes. Thanks in advance

Jeremy Johnstone's picture
Joined: 2011-04-17
- (Reply to #3) Sep 15, 2011

Hi Keshab,

You can call any method in the "server side" REST API in Javascript using IN.API.Raw(); You take the same URL which is listed in the documentation for the REST method and pass it to IN.API.Raw() in Javascript and the result will be returned as usual.

Bhavika Patel's picture
Joined: 2012-02-27
Mar 20, 2012

I am working with LinkedIn API and trying to call for "Start Follow a Company". My API request is as follows

var url = 'people/~/following/companies',
body = {
company: {
id: '1009'
}
};

IN.API.Raw()
.url(url)
.method("POST")
.body(JSON.stringify(body))
.result(function (result) {
console.log(result);
})
.error(function (error) {
console.log(error);
});

But,it isnt working. Am I doing something wrong in this? Kindly help me out with this.

Regards,
Bhavika Pate;

Paul Mennega's picture
Joined: 2009-11-30
Mar 20, 2012

Hi Bhavika.

It looks like you are missing a backslash in the url, and that the passed JSON is incorrect. Can you try the following?

1
2
3
4
5
6
7
8
9
10
11
12
13
var url = '/people/~/following/companies',
body = {"id": "1009"};
 
IN.API.Raw()
  .url(url)
  .method('POST')
  .body(JSON.stringify(body))
  .result(function (result) {
    console.log(result);
  })
  .error(function (error) {
    console.log(error);
  });
Bhavika Patel's picture
Joined: 2012-02-27
Mar 21, 2012

Hello Paul

As you mentioned, My JSON was incorrect. Now its working fine.
Thank you very much.

Regards,
Bhavika Patel

Joined: 2012-07-07
Jul 13, 2012

I am using the code posted in this forum for count of people following company..
NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/following/companies/"];

OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:oAuthLoginView.consumer
token:oAuthLoginView.accessToken
callback:nil
signatureProvider:nil];
NSDictionary *updates = [[NSDictionary alloc] initWithObjectsAndKeys:
[[NSDictionary alloc]
initWithObjectsAndKeys:
@"1009",@"id",nil], @"company", nil];

[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"json" forHTTPHeaderField:@"x-li-format"];
NSString *updateString = [updates JSONString];

[request setHTTPMethod:@"POST"];

I am getting response as
responseBody:
{
"errorCode": 0,
"message": "Invalid value {} in key {id}",
"requestId": "6YIWTGFUH4",
"status": 400,
"timestamp": 1342188977791
}

can anyone tell me where is it going wrong?