Fetch company posts and comments with Linkedin API - api

I'm trying to fetch LinkedIn company page posts using the LinkedIn API. I created my app with permissions set up, and I verified the company. Then I used this URL for which I created an authorization token:
https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=xxxxxxxxxxxxxxxx&redirect_uri=https//linkedindata.cresol.in&state=foobar&scope=r_liteprofile%20r_emailaddress%20w_member_social
and using this API:
https://www.linkedin.com/oauth/v2/accessToken
I got the accessToken and then used this in the Header like this:
Authorized :
Bearer AQUau_EPV1RVuoclp2BXRGBXjvDDCS2fsULTeNDBD5xmRohRW3q7nbVu9FFfeeucPUYCnGub1erfCu1IUF66QJhW5JxpiTx160vZwWHjwdeykm33vOmGFr1avSRCBPDYlZS ....
It's working fine for this API:
https://api.linkedin.com/v2/me
I get the proper response.
But once I used the same thing in another API, like
https://api.linkedin.com/v2/shares?q=ownersowners=urn:li:organization:82091933&sortBy=1&sharesPerOwner=100
I get this error response:
{
"serviceErrorCode": 100,
"message": "Not enough permissions to access: GET-owners /shares",
"status": 403
}
How to find the Listing of all posts of my company page?
What are the right endpoints and API for this?

First did you grant all permission before getting the Bearer token?
Second to get posts of an organization try this endpoint
POST https://api.linkedin.com/v2/posts?author={author}&isDsc=false&q=author&count=10
{author} = You need the organization id, and the max count is 100
Don't forget to add 'X-Restli-Protocol-Version: 2.0.0' at the header
Please check this link for more details LINKEDIN DOCS.

Related

Xero API seems to return two different UUID's for the same user

We're using OAuth2 to allow users of our system to connect to Xero. Once the authorization succeeds, Xero provides an access token with information about the user who made the connection, including a xero_userid.
However, using this ID to find the user via the Users API fails with a 404. The Users API shows a different ID for the same user.
Is there a reason these are different? And how can we use the xero_userid returned in the Oauth2 flow to find to the Xero user via the Users API?
In XERO, the xero_user_id you extracted from access_token is the internal userID that XERO uses to recognize the contact. So If you use the same the GET API will return 404 as it is not accepting the internal user ID, instead of that If you pass the CONTACT ID of the User it will return 200 with details.
At the same time, If you want to get the login user details(contact information), better call the /User API directly with the token, it will return the details and the response contain the contactID of the user in UserID field (I know a bit complicated)
Please refer to the screenshot for more details.

Get information about the user google plus api by token

I use the application android and get a token when making a request:
oauth2:server:client_id:xxxxxx.apps.googleusercontent.com:api_scope:profile email openid
After that I want to get information on this token on the web server.
I'm trying to use:
https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=xxx
But I do not get to get the data, how can I get it?
To get a real token, you need to correct the request for url:
https://www.googleapis.com/oauth2/v4/token
and pass parameters by the POST method:
grant_type=authorization_code&client_id=xxxx.apps.googleusercontent.com&client_secret=xxxx&code={code}
code - a token of the type previously obtained 4/xxxxx

Twitter GET users/search client_credentials: Your credentials do not allow access to this resource

I have a static list of music artists and i want to get the id or screen_name of each one of them in Twitter.
I found this api endpoint: users/search which allows to run a query on Twitter and get all the accounts that match with the query. For example:
https://api.twitter.com/1.1/users/search.json?q=muse
will return all the accounts that match the query "muse".
I need to call this endpoint in client_credentials flow, i don't need any permission by the user (which is only me in any case). The problem is that Twitter returns the following response when i try to access the endpoint in client_credentials flow:
"message": "Your credentials do not allow access to this resource", "code": 220
I have tested other API endpoints such users/show, statuses/retweets, statuses/user_timeline and they all works in client_credentials, just the one i need doesn't work.
Is there anything i can do about that? Or i must change the OAUth flow?
mentioned error,
"{"errors":[{"message":"Your credentials do not allow access to this resource","code":220}]}"
comes when requesting an end point which requires a user context (such as statuses/home_timeline) using application only token.
You can verify whether or not same error comes for end points like statuses/home_timeline or statuses/retweets_of_me. These end points work only in some twitter user context. The end point that you want, users/search, also requires user context.
I am suspecting some issue in obtaining oauth token and secret. How are you getting authorized tokens for a given twitter user account?

LinkedIn API - get information about my ALL Connections

I have used Facebook API but I am new to Linkedin api.
I need some help on how to get information (name, birthday, etc) about my ALL Connections, and I need help with both the token and the info-related API calls.
As for the token -- in Facebook there is the Facebook Console to generate tokens at runtime and test our API calls... Does LinkedIn have something similar?
Update: I'm able to get list of connections using:
http://api.linkedin.com/v1/people/~/connections?modified=new
... but how can I also get birthdates (if shared publicly)? I've attempted:
http://api.linkedin.com/v1/people/~/connections:(headline,first-name,last-name,date-of-birth)
...however, that shows me the first and last name but NOT the date of birth.
You can use the rest console here: http://developer.linkedin.com/rest-console
There is a template method you can use called "Get My Connections".
I hope this helps.
Update: LinkedIn has restricted their open API access, and this no longer works.
https://apigee.com/console/linkedin
Select OAuth2, click connect, then allow LinkedIn to privede apigee to your LI profile. Then in the left collumn, select Get My Connections. apigee prepares most of params, except format (xml/json), which you can add yourself.
Looks like now no such API available(Looks like depricated by Linkedin). Please let me know if i am wrong and suggest other ways to achieve user's connections.
I am getting this in response
{
"errorCode": 0,
"message": "Access to connections denied",
"requestId": "6Sxxxxxxx",
"status": 403,
"timestamp": 14xxxxxxxxx
}
Please see : https://developer.linkedin.com/support/developer-program-transition
I think what you are looking for, is the Linkedin Connections API. You can look at the documentation provided here -> http://developer.linkedin.com/documents/connections-api
There are also various other APIs for accessing profile, groups, companies, and jobs.
It returns an XML document so, you should be able to generate tokens and test your API calls without any problem.
These APIs are no longer available
2019 still works but with a different approach.
Do this:
You may follow the steps from here:
https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/consumer/context
1 - Create an APP with r_1st_connections permission
2 - Authorization (STEP 2 from link)
GET https://www.linkedin.com/oauth/v2/authorization
scope should be r_1st_connections (your app must have this permission)
3 - Log in with your username and password
4 - Linkedin will return you code
something like: ?code=QWERTY
5 - Get your Access Token (STEP 3 from link)
POST https://www.linkedin.com/oauth/v2/accessToken
6 - Get your connections
GET https://api.linkedin.com/v2/connections?q=viewer&start=0&count=50
Link: https://learn.microsoft.com/en-us/linkedin/shared/integrations/people/connections-api?context=linkedin/compliance/context

Tumblr API - OAuth issues: OAuth verifier and RESTConsole

Trying to obtain blog followers using Tumblr's API and RESTConsole in Chrome (not building an app, just want to check a request response).
I'm new to Tumblr's API and to RESTConsole, so two sources of possible error here.
I've already ...
Registered an app on Tumblr, receiving OAuth Consumer Key and Secret Key in the process.
Entered into REST Console my target: http://api.tumblr.com/v2/blog/{blogname}.tumblr.com/followers
Entered into REST Console's "Setup oAuth" window my OAuth Consumer Key and Secret Key, along with Tumblr's Request Token URL, Access Token URL and Authorize URL.
Approved read/write access to my application when prompted by Tumblr.
Entered the provided Token Key and Token Secret into REST Console's oAuth window.
When I attempt GET requests for follower counts (on my own blog or others'), Tumblr returns 401, "Not Authorized." My blog's preferences page lists the application I'm trying to use as having access.
I've tried this placing base-hostname:{blogname}.tumblr.com in REST Console's request parameters fields; I receive the same error. I tried running a different OAuth method from Tumblr's API (queued posts) and receive the same error.
Help?
Thanks. Let me know if this isn't clear.
Edit: Sorry, meant to add -- I think I may need Oauth Verifier. I haven't been able to find this token, or understand how to obtain it.
Edit (2): So, turns out Tumblr's API needs a comma separator from the REST Console. Thanks all.
''
Zack
$conskey = "CONSUMER KEY";
$conssec = "CONSUMER SECRET";
$tumblr_blog = "myblog.tumblr.com";
$to_be_posted = "This is the text to be posted";
$oauth = new OAuth($conskey,$conssec);
$oauth->fetch("http://api.tumblr.com/v2/user/following", array('offset'=>0) ,OAUTH_HTTP_METHOD_GET);
$result = json_decode($oauth->getLastResponse());
foreach($result->response->blogs as $key){
echo $key->url;
}
The code above will retrieve your followers list.
Hope this helps.