How to make join in rest api like in sql? - json

I am currently new in programming especially in front end and I was wounder how to perform join in Json Restful API
I am using Json placeholder for my fake rest api
I have tried reading their document by I failed
https://jsonplaceholder.typicode.com/posts/20
https://jsonplaceholder.typicode.com/users
I want to join these two tables
and display title,body from posts and username from user according to the userid in post

It seems like you will have to either create an endpoint in your backend that would perform the read from two joint tables and return a DTO having all the fields that you require, or (if that's impossible) you will have to call both endpoints in your client. So for example you could fetch the users in one call, then retrieve posts in separate calls and write front-end logic to find the associated user and display the data you need.
Ex. call api to get users, store them in a users array in your front end client code, then call api to get post and search for the corresponding user in the user array by userId

Related

Search Members using MailChimp API 3.0 by Merge Field

Is is possible to search for members in a MailChimp list by merge field using the MailChimp API v3.0?
The documentation for the Search Members endpoint links to a separate page, Search for Campaigns and Contacts in Your Account, which details how to manually search using the GUI, but mentions that the keyword search can include merge fields in the format merge3:keyword, so it looks like it should be possible.
However, in both the GUI and using the MailChimp API php wrapper, I get no results - the GUI returns the error Invalid search request, try again, while the php API returns an empty array with nothing in getLastError() or getLastResponse().
Searching using a subscriber's name or email address does, however, work as expected.
As mentioned by #Kalyan Sangartula it is not possible to search using other merge fields.
But I think an alternative, for now, to this could be using segments. You can create segments based on filters you want (api route "/lists/{list_id}/segments") and get members from those segments (api route "/lists/{list_id}/segments/{segment_id}/members").
"/search-members" endpoint only supports merge1, merge2, and merge3 fields (the Email, Fname, and Lname) fields for members. It doesn't support any other fields or merge fields except the mentioned above.
Sample API call for search-members: "/3.0/search-members?query=abc#example.com"

How to take user input from api.ai(dialog flow) and store it in mysql database using php?

I want to take the user inputs through api.ai(dialog flow) chatbot and store it in MySQL database like asking the user details of name, age, contact num through chatbot and then the user details are to be stored in my database i.e.., MySQL database. After storing, at last, the chatbot should show the summary to the user for confirmation.
I am able to interact and continue the conversation with my chatbot but unable to store the user's inputs.
I was searching at different places but I can't get the right process. I am comfortable with PHP to get the data from api.ai and to store in MySQL database.
Any help would be appreciated.
"Thanks in Advance!"
You need to create a webhook to handle fulfillment from Dialogflow. This will be a publicly accessible URL that can take an HTTPS POST, with a JSON body. In your case, this will be your Heroku URL that you will enter into the Fulfillment tab in Dialogflow.
See https://dialogflow.com/docs/fulfillment for information about the JSON you are sent, the JSON you'll need to reply with, and other information you need to setup fulfillment.
In your PHP code - you can do whatever you want with the data being sent to you, including storing it in MySQL. You'll then send back JSON (see the above URL for the format) indicating how you want to reply to the user.

Can groups be expanded when querying which students are associated with a class notebook?

We currently query for the list of students associated with a class notebook via:
/api/v1.0/me/notes/classnotebooks/{id}/students
Should a group be associated with the class notebook then we get principalType=Group and an id in the form:
c:0o.c|federateddirectoryclaimprovider|{id}
So is it possible to expand the members of the associated group(s) within this call? If not, what is the format of this id? To use it via the graph api requires an id so is it safe to assume that the id will always be the 3rd piped element?
Thanks
I ran into this for my application as well. After conferring with the onenote team a few months ago it came down to that you cannot expand these groups inside the onenote api. You must authenticate to the graph api and use the groups functions there. The downside of this is that the graph api permissions to expand a group require an administrator to grant them. So in the end all I could do was recommend the users create class notebooks using the student email list rather than an azure group. (on your final point the format should remain consistent the third piped element is the group id you can pass the graph api)
specifically the below endpoint to get a groups members
'https://graph.microsoft.com/v1.0/myorganization/groups/' . $group_id . '/members'

App scoped user ids

I have two facebook applications with their own access tokens.
I have followed this guide to create a business and associate the aforementioned apps to this business.
I now have a token for business from doing a graph api call -
/me?fields=token_for_business
When doing a regular api call without referencing this token for business, I can return app scoped user ids who have been invited to events for example like so -
https://graph.facebook.com/v2.3/{FaceBookGroupID}/invited?access_token={MyAppsAccessToken}
Where MyAppsAccessToken varies depending on the app, thus resulting in different app scoped user ids being returned depending on what access token is used.
After getting the token_for_business I updated my call to -
https://graph.facebook.com/v2.3/{FaceBookGroupID}/invited?token_for_business={MyTokenForBusiness}&access_token={MyAppsAccessToken}
My assumption was that now the applications are associated to the same business and have a link token, the calls would have brought back the same user ids in the JSON response, however this is not the case and regardless of appending the token_for_business parameter to the url, the same JSON responses are returned as the first call.
Is it possible to return the same user ids with two different access tokens?
No, different Access Token means different App, means different App Scoped ID. You can only use the Token for Business to match different App Scopes.
Btw, the call with token_for_business as parameter does not make any sense. The token is for one user.

Cannot fetch rooms through EWS API

I always get an empty response when I try to use the GetRoomLists web-service: https://msdn.microsoft.com/EN-US/library/office/dn643730%28v=exchg.150%29.aspx#bk_GetRoomListewsma
However, with the same account, I can correctly see rooms when I am using Outlook.
If I watch the network activity when I use Outlook, I can see that roughly 3 calls are made:
GetRoomLists is called and an empty result is returned
GetRoomsInternal is called and this time rooms are correctly being returned
GetUserAvailabilityInternal enables to fetch the availability of each rooms returned by GetRoomsInternal
It looks like GetRoomsInternal and GetUserAvailabilityInternal are exactly the API I want to call. Besides, these API seem to be private since they are not documented.
Is there a way to fetch all rooms using the public API ?