Linkedin API does not return phone number - php

I'm trying to retrieve some information about the user via Linkedin API, such as name, location, email address, phone number(s). The first three ones are returned perfectly, but the phone number is not returned for some reason (the field isn't even included in the return set). I have added it later, so I guess in might be some caching on the Linkedin's side.
All the permissions are included both in request and in the app's settings, the scope is: r_basicprofile r_emailaddress r_fullprofile r_contactinfo w_share
The query URL is: https://api.linkedin.com/v1/people/~:(id,first-name,last-name,phone-numbers,location:(name),email-address)?format=json
What might me the reason?
Thanks in advance!

An additional investigation has shown that to obtain any field from the full profile (including phone) it is necessary to request an ability to use this permission for your application via Apply with LinkedIn program.

Related

Azure Single Sign On - Redirect Loop

I have a problem setting up simple single sign on with Azure AD for our pHp website. The app is registered in azure and I have all the necessary details like Client ID, secret, tenant.
My requirement is to get authorized and also pull back the user's employee id, name and email id. I am working on single sign on for the first time, and need some help on this.
While creating the authorization URL, I am requesting for code, which is right according to the Azure documentation. I am successfully able to retrieve the code after authorization. However, I am not able to request id_token along with code as response_type=code+id_token, which should be possible. I could trace the URL flow and extract the id_token field manually. If I do this, I am prompted with the logon and MFA. But the response goes into infinite loop by just prompting with infinite number of MFA pings on my phone. This is weird, my program has a check to redirect on code response, which doesn't seem to work. I have tried using session_id cookie too, which has the same behavior.
If I just choose code as response type and request for id_token using token granting URL, I don't get any response back. Its blank or null but no errors.
Can you please help suggest if I am making a mistake. Is my method right or wrong to request code first and token next. How can I successfully retrieve id_token.
Just summary the comment into reply to help others who have the same problem.
response_mode: Specifies the method that should be used to send the resulting authorization code back to your app. Can be form_post or fragment. For web applications, we recommend using response_mode=form_post, to ensure the most secure transfer of tokens to your application.
If you want to use code + id_token in the response_type,you should be using OIDC Hybrid Flow.
However, if you just use code in the response_type, you should be using Authorization Code flow.
For more details, you could refer to this SO thread.

MailChimp sending incorrect user IDs

EDIT: There's a chance I may have been a complete bonehead and mistook USER:UID for the member's ID when in fact it may be referring to the account admin ID. I have changed it to simply include the member's email address as the last URI segment. Is that an acceptable approach?
I'm setting up an EDM in MailChimp that includes a link to a website form. The URL is structured like so:
http://domain.com/foo/*|LIST:UID|*/*|USER:UID|*
The idea is that some PHP on that page gets the member info using the list ID and the user ID in the API (3.0) endpoint for use in a cURL operation:
$url = 'https://us4.api.mailchimp.com/3.0/lists/' . $listid . '/members/' . $userid;
The retrieved data would then pre-populate the form so that the user could edit the information and submit to 1) store the record of the submission locally in the CMS, and 2) send a PATCH command to the API.
This worked fine in my testing with a different MailChimp account, but when switching over to the production account, the *|USER:UID|* merge tag started sending incorrect hashes. I even changed the list but the ID stayed the same, and neither IDs were valid MD5 hashes.
To be clear, this is not an issue with authorization, I correctly changed the credentials (API key and username) and data center in the URL. If I manually enter a valid user ID into the URL the information is retrieved successfully. I simply can't get the correct user IDs to be embedded in the email.
Additionally, my initial testing using PUT instead of PATCH failed if the entered email address was not found in the list, sending back a message to use PUT (which I was).
Yeah, passing the email address back to your page is likely the best option for you here.
I know this question is old, but perhaps you were looking for *|UNIQID|* instead of *|USER:UID|*? According to MailChimp's documentation:
*|UNIQID|* Pulls in the $member->email->unique_id; (API function).
If used in an email campaign, this tag will pull in your subscriber's
unique ID. It can also be used to create unique links for subscribers.
The merge tag you were using, *|USER:UID|*, simply says:
*|USER:UID|* Displays the "u" parameter from your hosted Mailchimp audience forms.
While their documentation does not specify what the "u" parameter is, this other stack overflow answer to a related question mentions that it is an identifier for your account, which is exactly the same conclusion you came to in your question's edit :)
Personally, I prefer to pass unique IDs as opposed to email addresses for the sake of privacy. Some of my clients put a high value on privacy and security so we do not pass any personally identifiable information (PII) where it could be intercepted.

api security implementation php

I have a site that allow users to check their statistics (number of file uploaded, how many files they have, quotas, type of access etc...)
I create a section on my site: api.domain.com
This can be access via curl or a web browser since I am returning a json object or xml (depending on the user prefs)
My question is this: should I restrict the access using a user/pass or should I create a hash of the user file?
for example:
scenario 1:
The user create a php curl that sends user and pass via post or the curl auth and get back the results, parse it etc...
For me this is secure but the user has to maintain his script if they change their pass
scenario 2
The user access a file like: api.domain.com/j355HGssgf3HESAjh45jusf4325GSj5hbsHhdh5HGHFS3732he4548475wbe3447nSNe5XfgjhGJ and then access the data
This one, nothing to maintain
Here's my thoughts on this.
If you return a page not found or an error message (with a good 200 OK status) when a request is made to your page, it might send to bots or UN-trustable people a clue on what can they get and try again and again and again ...
On the other hand, if you send a access denied, like a 401, or better a 500 error code to simulate a server error, these bots or UN-trustable people might go away for good.
I will say the user/password method is a little more secure in this case.
Now, would you trust simply entering a big string (like scenario 2) when you check your mail? or your bank account information?
If it was me I would give each account the ability to create a unique api key,
api.domain.com/?key=<API.KEY>
for more security measure you could make it only accept connection via the post method with the api key. If contacted via get then show an error etc.
Then if they change their pass/username it won't affect their api key

Linkedin Profile API vs Publicly Available URIs

I have a database of people's names and LinkedIn profile URLs.
Annoyingly there isn't a standard format for LinkedIn URLs (like twitter) but there are generally in the form of:
1) http://www.linkedin.com/in/geoffroyondet
2) http://www.linkedin.com/profile/view?id=34178115
On my site I want to display people's LinkedIn details.
I've got OAuth working fine and for people with the first format (above) I can successfully display their LinkedIn data on my site. I'm using the "Public Profile URL" option from https://developer.linkedin.com/documents/profile-api
But for the second format I'm having problems. It's invalid as a "public profile" and the ID in the URL doesn't seem to be the "member_id" from the link above.
Btw, if I try to use this numeric ID as a member_id I get the following error:
object(SimpleXMLElement)[652]
public 'status' => string '404' (length=3)
...
public 'message' => string 'Invalid member id {34178115}' (length=28)
From poking around with the API the only way I can get the alphanumeric id (member_id) is from a successful API call (blah->person->id). But to make a successful API call I first need a valid URI. So it seems to be a chicken and egg situation.
Any suggestions as to how I can display LinkedIn data by using the second URL above?
Looks like there are two issues here at play:
1) The technical issues. You are correct that you cannot retrieve a user's profile via the Profile API via the second URL, you can only do it via the unique public-profile-url, via the member ID, or via the ~ to retrieve the current user's profile.
Member ID is not related to the number you see in the query string - the member ID is a alphanumeric token generated uniquely for each user for each API application, so user A via your application will have a different member ID than the same user A via my application.
Are you just retrieving the member profiles arbitrarily or are you trying to retrieve profile information from connections of the viewing authenticated user? You should be able to either pull the viewer's connections public-profile-url, or pull it via a People Search, etc.
2) The platform guidelines. Basically, you can only show profile information about a particular LinkedIn user to viewers by pulling the information on behalf of that user. Meaning, that the viewer has authenticated against the API; you don't mention whether this will be the case, but adhering to #2 will potentially help solve #1.

Problem using Linkedin API

I am using linkedin api to get info about the logged in user. I am able to get firstname and lastname, picture etc., It works fine. But I am not able to get recommendations. I am able to get number of recommenders using num-recommenders.
I am not getting **recommendations-received** according to http://developer.linkedin.com/docs/DOC-1061. I printed out the json response no recommendations Object for the user.
I appreciate your help.
For unfortunate reasons, if you want to get access to that field, you need to replace IN.API.Profile().fields("firstName","lastName","recommendationsReceived") with IN.API.Raw("/people/~:(first-name,last-name,recommendations-received)").
This is a good thread to read on the LinkedIn Developer forums: http://developer.linkedin.com/message/8805

Categories