Facebook Graph API friends' names and ids - javascript

I know that if I simply try to get a list of my friends, it will only return app friends AKA friends who also have given permissions to Facebook
So, rightfully so, when I do a GET 'me/friends', I only see 5 friends.
However, when I do a GET me/posts/?fields=likes.fields(name), it obviously returns data with a list of friends who have liked my posts:
{
"id": "post1id",
"likes": {
"data": [
{
"name": "name1",
"id": "id1"
},
{
"name": "name2",
"id": "id2"
}....
]
}
It shows all friends, so non-app and app friends.
My question is, if all I want to use is my friends' names and id's from this result, would it be allowed, considering that some of these friends are not app-friends?

If you work the API with the user token, you may receive all likes (including friends who don't use the app, non-friends, friends who use the app, pages) but this is at all no indication for a users friends. Anyways you can utilize ALL data provided by the GraphAPI as long as you don't work around the limitations with something like exploiting the game invite feature.

Related

For Prisma Client join queries is it possible to move deeply nested fields to top level of result?

Does Prisma have the ability to move nested fields from another table join to the top level of the result, like a flattened view? I want to put the result JSON into a frontend table without digging through nested objects and building another object.
For example I want to replicate this behavior where I can pick and choose the columns from different tables (columns from User, and School). Currently I use a raw query with a similar SQL, however I wonder if it's possible with using only the Prisma API:
SELECT
u.id
, u.email
, s.school_name
FROM "User" AS u
JOIN "UserSchool" AS us ON us.user_id = u.id
JOIN "School" AS s ON s.id = us.school_id
id | email | school_name
123| student1#email.com | mount high
I want JSON that looks like this:
{
"id": "1",
"email": "student1#email.com",
"school_name": "mount high",
}
If I did this in Prisma, I would need to go into several levels of nested objects to get the same column name on another table for e.g. user[user_school][schoo][school_name]. This requires extra work to loop through all my results, extract from the nested object, and build another object. This example isn't too bad, but I have more joins and deeply nested objects for my actual problem (lots of association/lookup tables). I've experimented with the select and include for my joins, but they are structured with the nested JSON.
users = await prisma.user.findMany({
include: {
user_school: {
include: {
school: true,
},
},
},
{
"id": "1",
"email": "student1#email.com",
"user_school": [
{
"id": 1,
"user_id": "1",
"school_id": "1",
"school": {
"id": 1,
"school_name": "mountain high",
}
}
],
}
It's not possible to flatten out the results as of now.
The only way to achieve this would be by using rawQuery as you mentioned.
However, there is an existing Feature Request which discusses Flattening out the results by providing an option of flatten:true. If you could mention your use case there and add a comment it would help Prisma's Product and engineering team in prioritising it.

How can I retrieve popular users from GitHub?

I am trying to get a list of popular repos and users on GitHub.
Their API has an example to find users given some criteria that must be sent under the q query param, this is a required parameter but I am not sure how to send it as 'empty'
The query should list users and sort by followers, I am close but I am not sure what to send in q
`https://api.github.com/search/users?q=${WHAT_WHOULD_GO_HERE}&sort=followers&order=desc`
Just for reference, I was also trying to get popular repos and this is possible with the following query and it works just fine:
curl https://api.github.com/search/repositories\?q\=stars:\>1+language:javascript\&sort\=stars\&order\=desc\&type\=Repositories
You can run a query by specifying the follower limit, repository language, and page on the Github API. If you can configure the queries correctly, you will get what you want.
Sample query
`https://api.github.com/search/users?q=repos:followers:<1000&language:javascript&page=1&per_page=100`
For example, I can fetch all users with more than 2000 followers. This is also getting a kind of popular users.
`https://api.github.com/search/users?q=repos:followers:%3E2000&language:javascript&page=1&per_page=100`
Response
{
"total_count": 321,
"incomplete_results": false,
"items": [
{
"login": "vim-scripts",
"id": 443562,
"node_id": "MDQ6VXNlcjQ0MzU2Mg==",
"avatar_url": "https://avatars0.githubusercontent.com/u/443562?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/vim-scripts",
...
}
After fiddling around I got the answer:
curl https://api.github.com/search/users\?q\=followers:\>1000\&page\=1\&per_page\=10\&sort\=followers\&order\=desc
The query is based on Github's own popular list which has some clues in its own URL, the query above returns the exact same result
https://github.com/search?o=desc&q=followers%3A%3E%3D1000&ref=searchresults&s=followers&type=Users
The q query param needs only this:
followers: >1000,
Plus some sorting as described in the question:
sort: by the followers count,
order: descendent

Adding and removing items from a cart in Dialogflow

I am prototyping a Food Ordering app using Dialogflow(Chatbot maker) and got stuck with this problem. Technically, I want to persist the gathered data from an Intent after the user decided to "add more items to their order" and satisfies all the required parameters, which are, (itemName, quantity, [variants], [sauceType], ...).
The chat bot should be able to handle a request which consist of multiple items with their corresponding quantities but I am not sure if it's possible to model a data wherein it consist an array of Entities so, my first thought was to use a persistent Fulfillment using session-based Webhook with our custom Web Service, like for example: foodorder/api/order/123/items/add and 123 being the Session Id. But this approach requires more work and the generated model can be difficult to translate in Dialoflow Console.
The second solution comes into my mind, is to leverage the Intent property called Action and Parameters where we mark the Entity as List, but using this approach, the quantity doesn't get attached to the item itself.
My question is, how can I be able to model a data using Dialogflow that resembles something like below:
{
"givenName": "Dummy User",
"order": [
{
"itemName": "Burger",
"quantity": 2
},
{
"itemName": "6 piece Chicken Nuggets",
"quantity": 1,
"sauceType": "Tangy Barbeque"
},
{
"itemName": "Coke",
"quantity": 1,
"size": "Small"
}
]
}
Turns out what I was looking for was Composite Entities and mark it as a list.
The detailed answer can be found on this link:
https://stackoverflow.com/a/47166123/2304737

Firebase linking users across application with unique identifier

I'm using firebase and my users are set up like this:
{
"firebase-account-123": {
"users": {
"simplelogin:1": {
"properties"{ "name": "john doe", "email": "user#email.com" }
"children": {
"simplelogin:2":{ "name": "user 2", "email": "user2#email.com" },
}
},
"simplelogin:2": {
"properties"{ "name": "user 2", "email": "user2#email.com", "disabled": false }
}
}
}
I use simplelogin:X and the users email across many objects in my database. I know using this to identify my users across different objects is probably a bad move.
At some point I am trying to implement the ability to change emails which means that their simplelogin ID is going to have to change along with every email property that ever linked to their email.
Does anyone have any suggestions on how I can link users to one another without have to change their data if it changes across the entire platform? I'm thinking somewhere along the lines of a unique identifier for each users. I just don't know how I would implement this.

get facebook users data of his reads in washington post or yahoo reader

Is there any way to get the reads of a user in washington post or yahoo reader?
I have checked http://developers.facebook.com/docs/reference/api/ where one gets access to news feed and profile feed, but they dont gives what the user has read in washington post / yahoo reader. Is there any way to get this information using javascript jdk?
What I have tried:
After login in thorugh the login in button. I query
FB.api('/me/washington_posts', function(response) {
var wash_post=JSON.stringify(response);
alert(wash_post);
});
graph.facebook.com/me/317071798339058?access_token=AAAAAAITEghM...
graph.facebook.com/me/...
I tried sevaral combinations of washington_posts, but always got error. I know this was not going to work but tried for some luck There is no documentaion of the same as mentioned here.
I believe its not possible to get it as of now as wpsocialreader is a diiferent fb app. apps.facebook.com/wpsocialreader/… I am only able to get the app info.
graph.facebook.com/267401179951379 :
{ "id": "267401179951379", "name": "Washington Post Social Reader", "link": "facebook.com/wpsocialreader";, "likes": 169544, "category": "App", "is_published": true, "website": "washingtonpost.com/socialreader";, "username": "wpsocialreader", "description": ".........", "about": "News. Better with friends. ", "release_date": "2011", "can_post": true, "talking_about_count": 19977 }
I think it is not possible to collect data from washington post reader app, so I am looking if somebody have already done it.
You can get the entries with the open graph action type news.read from yourself or a friend using the graph API:
graph.facebook.com/me/news.reads or graph.facebook.com/USER_ID/news.reads
Obviously, add in the access token and other graph parameters you need as well. This will return all reads from the applications that publish them. You could then pick out the social reader reads by app id.
Hope this helps.
-matt

Categories

Resources