LinkedIn-J does not return educations - java

I am using LinkedIn-J. My application authenticates without problem, I get data from the user - even their first name, last name etc.
Person profile = client.getProfileForCurrentUser();
profile.getFirstName();
However, when I try to get the list of educations, the Educations object returned is null:
Educations educations = profile.getEducations();
educations == null
What can be the error? Should my application ask for special permissions to be granted?

I've never used the Linkedin-j api before, but according to the LinkedIn api you get firstname, lastname, headline, and some url by default.
So I believe you need to specify that you want education returned. I don't know how to do that in LinkedIn-J though.
http://developer.linkedin.com/documents/profile-api
For example, with the rest api you'd use this uri:
http://api.linkedin.com/v1/people/id=12345:(first-name,last-name, educations)
Using the LinkedIn J library, it seems like you have to add profile fields using Set as a parameter to one of their many methods in the client.
Example of a method you could call of many (if you have a connected user):
public Person getProfileForCurrentUser(Set<ProfileField> profileFields)
ProfileField is an Enum located here:
import com.google.code.linkedinapi.client.enumeration.ProfileField;

Related

Simple GET request with Facebooks API

I am currently taking a course in app development and I am trying to use Facebooks API for GET requests on certain events. My goal is the get a JSON file containing all comments made on a certain event.
However some events return only a an "id" key with an id number such as this:
{
"id": "116445769058883"
}
That happends with this event:
https://www.facebook.com/events/116445769058883/
However other events such as (https://www.facebook.com/events/1964003870536124/) : returns only the latest comment for some reason.
I am experementing with facebook explore API:
https://developers.facebook.com/tools/explorer/
This is the following GET requests that I have been using in the explorer:
GET -> /v.10/facebook-id/?fields=comments
Any ideas? It's really tricky to understand the response since both events have the privacy set to OPEN.
Starting from v2.4 of the API, the API is now declarative which means you'll need to specify what fields you want the API to return.
For example, if you want first name and second name of the user, then you make a GET request to /me?fields=first_name,last_name else you will only get back the default fields which are id and name.
If you want to see what fields are available for a given endpoint, use metadata field. e.g. GET /me?metadata=true

How t set FieldType.USER in sharepoint file property with Java - Invalid data has been used to update the list item

I'm trying o use method CopyIntoItems and add to uploaded file owner property. Field Owner should be type USER. am setting up it like this:
FieldInformation fieldInformationUser = new FieldInformation();
fieldInformationUser.setDisplayName("Owner");
fieldInformationUser.setInternalName("Owner");
fieldInformationUser.setType(FieldType.USER);
fieldInformationUser.setValue("domain//username");
I'm using this library: Sharepoint library link
If TEXT type field is updated in presented above way - it passes, but does't update field at SharePoint server. Problem occurs when i'm using type USER - server returns
Invalid data has been used to update the list item. The field you are trying to update may be read only.
WSDL specifies fieldType.USER as a string field. he question is, how this string should look like... Anyone knows?
You must make sure that the user exists in the users table in SharePoint. It may be that it exists in AD but it hasn't been added to SharePoint yet.
If it were C#, then you would first issue the EnsureUser command:
//C# CSOM code
SPUser user=web.EnsureUser(userName);
listItem[fieldName] = user;
You should search for a similar method in the library you're using

Java EE : Prevent application URL hacking

I am working on an existing Web based application.
Now, I need to secure the application against what I think is called url hacking. For instance, if the customer with customerId 1 is logged in and viewing his profile, the following http get variable will be visible in the address field: customerId=1.
I need to prevent a customer from being able to set customerId=2 and see the profile of another customer.
The problem is that, the application is already in production and in good working condition, so the changes should be minimal with respect to this change.
How is this best achieved?
Any sugggestions/comments?
why do you give the id in the URL when the user should only be allowed to change his profile? I don't see any need for this. Rather get the current user from SecurityConext and display its profile on an URL without the id.
with the new information you gave in the comments I suggest sth. like this:
just check if the given orderid in the URL belongs to the current user.
You're saying you use "normal web based Application" so I assume Servlet/jsp based. In your servlet you would do something like this:
int orderId = Integer.parseInt(request.getParameter("orderId"));
String username = request.getUserPrincipal().getName();
/*now you need to check if username match with the username of the order e.g. by using hibernate to get the order by id and check its user and if not throw PermissionDeniedException or similiar*/
95% agree with Korgen's answer above.
5% - if you want to allow administrator access to edit user profiles using the same functionality just switch to UUID to identify edited user.

Cannot get authenticated user info, but can get address book from Google Contacts

I ran into an interesting case where it seems to indicate that the documentation for Google Contacts API is incorrect.
What I'm trying to do is getting the contact information of authenticated user who has already given permission to the app using this URL:
https://www.google.com/m8/feeds/contacts/default/full/contactId
The result of the call is always status 404. However, when I'm trying to get full address book, it seems to be working fine.
https://www.google.com/m8/feeds/contacts/default/full
Is it documented incorrect or I'm doing something wrong? It makes no sense that I can get the whole address book without being able to get contact information of the authenticated user.
The scope I'm using is:
https://www.google.com/m8/feeds
Thanks,
Jack
Additional information. The API documentation shows the following:
public static ContactEntry retrieveContact(ContactsService myService) {
ContactEntry contact =
myService.getEntry(new URL("https://www.google.com/m8/feeds/contacts/default/full/contactId"),
ContactEntry.class);
// Do something with the contact.
return contact;
}
This seems to mean that "contactId" keyword should used as part of URL. It just doesn't work for me.
To clarify this question. The goal is to get information on current authenticated user without having to go through workaround of fetching data multiple times. Even with the workaround of fetching all contact first, I didn't see any contactId of authenticated user coming back with it.
It depends on what you are trying to get. If you call https://www.google.com/m8/feeds/contacts/default/full, then you are looking for all the contacts. Now, when you get back the contacts, you can request the data for a single contact by using https://www.google.com/m8/feeds/contacts/default/full/{contactID} where {contactID} is the last part of the field from the full contact list. It will look like http://www.google.com/m8/feeds/contacts/{user email}/base/{contact id}.
So, if you get back the full contact list, a single contact will have an ID field that looks like: http://www.google.com/m8/feeds/contacts/{user email}/base/{contact id}. If you take that last {contact ID} and append it to the end of the call (https://www.google.com/m8/feeds/contacts/default/full/{contactID} ), you will get back the contact information for just that contact.

How can I get the current URL in Google Web Toolkit via client side Java code?

I'm trying to read the query arguments of the URL in client side Java code, but I can't figure out how to find the current URL in Java.
When I tried using httpServletRequest as recommended in this question, it says that it cannot be resolved and it doesn't offer adding an import statement.
I'm using Google Web Toolkit with Google App Engine.
Look at Window.Location:
public static class Window.Location
This class provides access to the browser's location's object. The location object contains information about the current URL and methods to manipulate it. Location is a very simple wrapper, so not all browser quirks are hidden from the user.
There are a number of methods to retrieve info about the URL, including one to get the whole thing (getHref()) or get the constituent components (e.g. getProtocol(), getHost(), getHostName(), etc).
Since you say you want to read the query arguments, you probably want one of these:
static java.lang.String getQueryString()
Gets the URL's query string.
static java.lang.String getParameter(java.lang.String name)
Gets the URL's parameter of the specified name
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameterMap()
Returns a Map of the URL query parameters for the host page; since changing the map would not change the window's location, the map returned is immutable.

Categories

Resources