Happyr / LinkedIn-API-client

A library to connect with LinkedIn API. Perfect if you are looking for an API client or SDK for LinkedIn
MIT License
198 stars 97 forks source link

Historical Follower Data #140

Closed ghost closed 7 years ago

ghost commented 7 years ago
Q A
Bug? no
New Feature? no
Are you using composer? yes
Version

Actual Behavior

I was hoping somebody could help with this. I am unable to get the historical follower data from my company account using the api. I am able to connect and authenticate but unable to do anything after that.

Perhaps this functionality is not built into the api client?

Expected Behavior

I am hoping that I can return a json format of historical follower data in the same way as when I use apigee.

Steps to Reproduce

code below: require DIR . '/vendor/autoload.php';

$linkedIn=new Happyr\LinkedIn\LinkedIn('819ehyojqhis4x', 'pskKOktXc9NFuTWi');

if ($linkedIn->isAuthenticated()) { //we know that the user is authenticated now. Start query the API $user=$linkedIn->get('v1/people/~:(firstName,lastName)'); echo "Welcome ".$user['firstName']; exit(); } elseif ($linkedIn->hasError()) { echo "User canceled the login."; exit(); }

//if not authenticated $url = $linkedIn->getLoginUrl(); echo "Login with LinkedIn";

$options = array('json'=> array ('time-granularity' => "day", 'start-timestamp' => 1488326400000, 'format' => "json" )

            );

$results = $linkedIn->get('v1/companies/41732/historical-follow-statistics', $options);

echo $results; var_dump ($results);

Possible Solutions

I have looked through the code and I am unsure of the problem.

Nyholm commented 7 years ago

This client only helps you with authentication. That means the client is not opinionated how you query the API. Or in other words: All endpoints/functionality is accessible with the client.

What response do you get when dumping the $results = $linkedIn->get('v1/companies/41732/historical-follow-statistics', $options);?

ghost commented 7 years ago

Firstly thank you for the super quick response - very kind.

To answer your query I get nothing screen shot 2017-03-29 at 1 21 35 pm

I also tried adding some code to test is the variable is empty. But this also doesn't return anything, suggesting the script is stopping before that.

if (empty($results)) { echo "empty"; } else { echo "full"; }

Nyholm commented 7 years ago

A okey, How about removing the exit() call? (The one after "Welcome".) That is why the execution stops for you.

ghost commented 7 years ago

Highly embarrassing, thank you. You can see I'm new to PHP

Frustratingly I still dont get the desired response. screen shot 2017-03-29 at 3 00 38 pm

I've checked the get function that asks for $resource,$options and I believe all of them are set.

Resource = v1/companies/41732/historical-follow-statistics Options = my array (i've checked the time is correct)

I think maybe its because I'm not passing my token back with the get request?

Nyholm commented 7 years ago

No you should not care about tokens. Read the error message. "Start time is required". You are using the wrong parameters.

Have a look in the API documentation and consult Linkedin about this error. It is not client related.