does Facebook Graph API support searching people's name? - android

I would like to search facebook user by thier name. For example, If I type 'James',
I would like to return facebook users whose name is 'James'.
I know it is possible to access user's info with user's id value. But is it possible to access
user's id with only user's first name or last name?

Sergey is right about the fact that searching for all people named James would be useless. Sergey is referring to FQL, which is a different way of querying data, but as DMCS pointed out, there is a search function in the Graph API that can enable you to do what you're trying to do.
https://developers.facebook.com/docs/reference/api/
I quote:
Searching
You can search over all public objects in the social graph with https://graph.facebook.com/search. The format is:
https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE
If you go to the page, there will be some examples of URL queries you can use to search for different types of objects, including users.
In my view, a useful application will typically be operating in the context of a FB user, accessing the objects that user has given the application permission to access. If you're searching a name among a user's friends, it's probably easiest to get all of his friends (you don't need any IDs to do this, other than the logged in user), and parse through that list for the user's name and ID, and then use the ID to get whatever information you're going to get.

It's really simple, do an HTTP GET to the Graph API search?q=James&type=user&access_token={token}

Take a look at this table https://developers.facebook.com/docs/reference/fql/user/
there're certain restrictions applied to that and required fields in the query because there can be millions of 'Jameses' and you will overload facebook's services with your queries as simple as that. They will not give you all the Jamses due to security and load reasons.

Related

How do I retrieve user's name and last name using FirebaseUI in Android?

According to this guide the built-in authentication of FirebaseUI should already handle this. Indeed, retrieving the current user and calling currentUser.displayName (Kotlin here) the string returned is "Lamberto Basti" that is my name concatenated with my last name. Is there a smart way to retrieve them separately?
Notice that I've enabled login with email, Facebook, Google and Twitter.
There is no API to get the separate first name and last name from Firebase Authentication. If you need the name in that format, you will need to ask your user for them (potentially pre-populating the UI based on their display name).
Note that splitting the string on a space to get the first name and last name may work in your tests, but will likely lead to problems as you roll out internally. To learn more about the intricacies, I recommend reading the W3C treatise about personal names around the world.

federated identities and modification of user attributes

In my app I want users to sign themselves up/in (through user pool I created) or through facebook. I have done this first approach and looking at facebook authentication now. Basically, I retrieve user info such as name, email, gender etc but I also want them to fill in missing information such as DOB, location or later on, if they wish, they should be able to modify those attributes. How can I achieve this ? Should I have a DynamoDB table and populate it with those attributes and let them modify it later ? Thanks for advice.
In addition to David's answer, you could use Cognito Sync to store each of those attributes as a record within a single dataset. Since you mentioned you have a Facebook provider linked, those'll be accessible cross devices and only visible to the owning user.
Dynamo is also a totally viable option, you could use Cognito's IAM permissions to make sure users can only see/update their own rows.
We added support for Federation through Facebook, Google and LoginWithAmazon for User Pools. This will create a user in user pool when a user logs in with federation. You can also capture the attributes from Facebook using the attribute mapping feature.
I would suggest aws cognito to help track the user attributes as you have e described https://aws.amazon.com/cognito/ it has a lot of those attributes built in and also allows you to create custom attributes.

How to make api.ai agent learn something dynamically?

I am currently using api.ai , to create agent to perform specific tasks, but one question i don't have answer to is , can i make it learn something while chatting , mean that i speak my name is 'John Cena' and she should store it and then whenever i ask her again bot should answer me that. i know there is a way to do it by logging into api.ai web and manually add entries , but it will not help, is there any work around programmatically or automatically ? the file i've been using to practice is given in github . and here is working DEMO
You basically need for your bot to "learn" facts. There are many different ways to achieve this, but recently the most common way is to arrange knowledge into Semantic "Triples" and store the knowledge into a Graph repository (like Neo4j, Titan, Spark Graph, etc). In your example, "my name is John Cena" would translate into a Triple like ("anubava","Name","John Cena"). That way, the next time you are logged in as anubhava and ask "What is my name?", it would translate into a Graph search that will return "John Cena". A word of caution, achieving this is not trivial and would require some significant amount of fine tuning. For more info, you can check here and here.
Finally, most complete solutions (that I know of), are Server Side solutions. If you want for the whole knowledge base to reside in your mobile device, you could probably use the resources there as inspiration, and build your own Linked Data repository using an embedded database.
Hope this helps. Good luck.
To store and recall the user's name, you'll need to set up a webhook with some basic data persistence capabilities. Any database or key-value store would work fine.
Here's the breakdown:
Implement webhook fulfillment for the intent that captures the user's name. The webhook should store the name along with a unique, identifying ID that you should supply from your front-end in either the sessionId or as a context parameter in your call to /query.
Implement webhook fulfillment for the intent that reads the user's name. The webhook should look up the name by ID and return a response that tells the user their name.
The high-level docs for writing a fulfillment webhook are here:
https://docs.api.ai/docs/webhook

Android facebook SDK 4.x getting user email without JSON

I want to ask how could I get user's which is logged into app email as string value? I have only seen tutorials how to get it using json and then send it to web service which I don't need. Maybe someone could show me the simple way of getting user email?
The Graph API always returns JSON. So, no, I don't think that this is possible. The Android SDK provides convenience classes, so I don't really see a big effort using those. You can use JSONObject.get("email") to retrieve to value of the email property I guess.
See
https://developers.facebook.com/docs/android/graph#userdata
http://developer.android.com/reference/org/json/JSONObject.html#get(java.lang.String)

How to best add a comment/rating system to an android app

I already published an android app where you can see a list of specific objects and detailed informations about them. The list changes every day but some of the objects can appear again.
The application is communicating with a PHP server over HTTP and periodically pulls the list of objects.
I now plan to extend the app to make it possible to rate the objects and add a comment similar to how it is done in the android market. I'd like to avoid forcing the user to sign up for an account for being able to comment.
I see two problems:
The comment-system could be abused by spammers
A comment could be added from another system
So my questions are:
How to protect the system from spam?
How to authenticate the application with the server?
How do I limit the number of comments to one per user and object?
What about the androids device id? Is it unique enough to use it as identifier for the user?
Which other problems do you see?
2020 Commenting/Rating/Reviews Options
Since Socialize is out, here are a few options you can explore:
Build your own comment/rating implementation. Personally I love reddit and how it handles nested comments and ratings. Here's a library I found that implements it beautifully. Please note you'll need to tie this with a cloud-database. This is based on groupie. Article & implementation. Many ways to do this - https://stackoverflow.com/a/59472206/668240
Disqus - SDK's coming soon to iOS and Android.
BazaarVoice - commercial
Social Networks SDKs like Facebook, Twitter, etc. Personally I dislike this as we'll need to authenticate users with respective networks to use the APIs. It's like we are shipping off users of our apps to social networks. If you don't have a problem with that - then it might be for you
Legacy Option in 2014:
You can try out Socialize SDK which is open-source and a really good SDK for the rating and commenting you are looking for. It already has a well-functioning Commenting system built-in along with a 'like/love' facility and sharing to FB and Twitter. Each 'entity' (object in your case) can have metadata associated with it. So all you have to do is construct/use a rating widget, then send that rating with the entity attached to your object. To display your rating/comment is as simple as retrieving them from Socialize.
Each object (element from your app) should be associated with an entity which has a unique key in the form of a URL - sort of like a primary key to recognize your items. This entity can have meta-data - any data that you can insert on behalf of your object. Once you do that, you can retrieve that metadata any time you want.
I've been using Socialize for around a year now. They've matured over this period and are always aspiring to be the best at what they do.
Look at the Socialize Bar at the bottom. Its can be customized to your needs.
What's more - Socialize is free.
As for your questions:
There is comment moderation built into the Socialize Web Component
where you can filter out anything you feel is out of place.
Socialize allows you to authenticate through Facebook and Twitter.
Limiting to one comment per user can be achieved by using their User
and Comments API.
Socialize has both Anonymous authentication as well as Social A/c
authentication. I believe you can remove anonymous auth. So that
ensure that every user is authenticated before rating/commenting.
For authentication, you could use OpenID like StackOverflow does or Facebook authentication. Once you have them authentication, it shoud be easy to limit the number of comments to one per user per object. As far as spam, you could follow StackOverflow's model and allow users to vote comments up or down or flag as spam. Perhaps users with comments that have been voted up would have more power and be able to flag comments as spam.
You'll need some sort of rate limiting. I've used this one in this example before.
So you need a table with the user's ID and how many api calls they have left, and then when their last api call was. Then use the algorithm to update the values in the table every time a method is called.
Read through this, I think it should be possible to create an UUID for every case:
http://android-developers.blogspot.de/2011/03/identifying-app-installations.html
And then keep a hidden api key which is hard coded, or at least get's everytime calculated the same or in enigma style influenced by the time it is used. But you will be never be sure, that it won't be find out by crackers/hackers and maybe abused, you will always have this Problem.
Authenticate with the UUID of the user + api-key.

Categories

Resources