I have a problem while fetching data from an array that I obtain with a fql query.
The data that I receive has this structure:
{
"data": [
{
"name": "Just Café Pacini",
"can_post": true,
"page_id": 401836073222759,
},``
{....},
{....},
]
}
I'm working with the php SDK and I'm trying to receive some informations about several pages.
I've tried with foreach($ret_obj['data'] as $single_obj) as usual but php tells me that there's no index "data".
I'm sure that facebook doesn't return any error.
first you must call json_decode($ret_obj) to get a php array
then you can call foreach to iterate
Related
I have started the programming in swift and trying to implement small search functionality.
I trying to implement search box for searching the different aircraft. For each character entered in search box, result should be refreshed.
I already have a API to get list of aircraft types. sample response type from the API.
[
{
"type": "jet",
"seating": "single-seat",
"engine": "Two-engine",
"name": "Lockheed Martin F-35 Lightning II",
"nativeName": "Lockheed"
},
{
"type": "turbojet",
"seating": "double-seat",
"engine": "Two-engine",
"name": "Heinkel He 178",
"nativeName": "Heinkel"
}
]
How do i search the aircraft using swift and result to be showed in the tableview and for each character entered in search box, result should be refreshed.
I'm using below link for reference but sample code would help a lot.
https://medium.com/#nimjea/json-parsing-in-swift-2498099b78f
Thanks
To get refreshed result from API, You have to check after received Response from API. Please refer below sample code for refreshed result.
if textToAPI != self.searchTextField.text{
self.aryResult.removeAll()
self.tableView.reloadData()
}else{
// Add new record into Array received from API
}
self.tableView.reloadData()
I call my mailbox using REST calls to MSGraph:
GET https://graph.microsoft.com/v1.0/me/mailfolders/inbox/messages
As expected I receive a Json with my mails.
To play with a specific mail (move, delete,forward, ...) I saw that the API should be called like
POST me/messages/{id}/forward
I can't target the message if I provide the value of the id field that I get from the JSon. Where to find the correct {id} that I should use?
my result is like the example at https://developer.microsoft.com/en-us/graph/graph-explorer see id: field when calling GET my mails.
Thanks
The id from JSON is OK. what you missing is you have not set the post conent for move/forward.
If you use the forward API, you should set the post content like below:
{
"Comment": "FYI",
"ToRecipients": [
{
"EmailAddress": {
"Address": "XXX#XXX.onmicrosoft.com"
}
}
]
}
This is the worked forward url for me(you can implement the move/delete like this too):
https://graph.microsoft.com/v1.0/me/messages/AAMkAGNjZTcyZDJmLTkzMjYtNGQwNi05Y2UxLTc5NDk0NjEwNjJjMABGAAAAAAAUYpVLVYiKTINMO3MZR0H5BwB3NF3PTyl5QIQd59edwRO9AAAAAAEMAAB3NF3PTyl5QIQd59edwRO9AAApBI9fAAA=/forward
For information please see:
https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/mail-rest-operations#ForwardDirectly
I am using MusicBrainz to get a track's meta data. I want to get the track's album's mbid. I am doing the following lookup using ISRC code.
https://musicbrainz.org/ws/2/isrc/USRC11600201?fmt=json
But in response I don't get any metadata related to the album of the track. I get the following response:
{
"isrc": "USRC11600201",
"recordings": [
{
"disambiguation": "single remix",
"title": "Cheap Thrills",
"id": "92e27a47-3546-4bc2-a9f7-b19e43d7a531",
"length": 223000,
"video": false
},
{
"length": 218540,
"video": false,
"title": "Cheap Thrills",
"disambiguation": "",
"id": "5845e975-33b4-4b0d-8e74-8f57d128b3d1"
}
]
}
I have tried various combinations of the "inc" sub query parameter as well but nothing works. Please help me out. I am really stuck at this.
Using inc=releases in the URL parameters should be enough to get you the information that you want. However, it seems like there's a bug with MusicBrainz's JSON web service (which is still officially in beta), as you can see in the difference between the XML and JSON end points' output:
https://musicbrainz.org/ws/2/isrc/USRC11600201?inc=releases&fmt=json (JSON) vs. https://musicbrainz.org/ws/2/isrc/USRC11600201?inc=releases (XML).
One obvious solution/work-around here would be to switch to using the more mature XML endpoint. If that is not an option, you can use the Recording MBIDs given in the JSON output to look up releases associated with those Recordings, e.g., https://musicbrainz.org/ws/2/recording/5845e975-33b4-4b0d-8e74-8f57d128b3d1?inc=releases&fmt=json (note that inc=releases is also needed here to get the information about the releases, and it actually works when looking up recordings).
So to get the details of the album of a track when I have the ISRC of the track, we need to do the following get request:
https://musicbrainz.org/ws/2/isrc/GBUM71604605?inc=releases
It will give a response in xml. The xml api is more stable click for more details on this
As I need the response in json, we can use a library like xml to json and vice-versa library
As much as I have seen the xml response from the MusicBrainz api is more accurate and gives a lot of information.
i am fetching records from Google big query using gem 'google-api-client',
When I fetch records from table
client.execute(api_method: #compute_api.tabledata.list,
parameters: {projectId: project,
datasetId: dataset,
tableId: table,
maxResults: 10}).body
I get response like,
{
"kind": "bigquery#tableDataList",
"etag": "\"iBDiwpngzDA0oFU52344ksWOrjA/-xEFKhLUueR63_XVaLG4z_mJt-8\"",
"totalRows": "2000113",
"pageToken": "BEIYURQ3J4AQAAAS23IIBAEAAUNAICAMCAGCBMFOCU======",
"rows": [
{
"f": [
{
"v": "11873943041"
},
{
"v": "639592585-0-1809110554#8.19.146.76"
},
{
"v": "1.430438401E9"
},
{
"v": "1.430438402E9"
},
{
"v": "1.430438404E9"
},
{
"v": "1.430438862E9"
}]}]}
Which does not have column names in it, Does anyone have any idea about how to get columns names along with data?
Currently I need to make another API request to fetch schema and get column names.
I found answer for this myself using bigquery command line tool (bq),
bq --format=json query "select * from calls.details limit 10"
when using bq if we dont provide --quiet option then it returns response with additional text to it(status about big query job), that causes problem in parsing Json as shown below
Waiting on bqjob_r36676afce1bcba8d_0000014f1ba0e36b_1 ... (0s) Current status: DONE
[{"status":null,"userfield":null,"answer_stamp":"2015-05-01 00:00:04","term_roid":"a"}]
Thats the reason I moved to use google api to fetch data and again that doesn't give you column names along with data. But I found that we can remove that extra text by using --quiet option for bq command like
bq --quiet --format=json query "select * from calls.details limit 10"
The API does not provide a way to get the schema and rows for an arbitrary table in a single API call. You need to call tables.get to get the schema, and then tabledata.list to get the rows.
However, if you're running a query, you can get the output schema and output rows in a single API call by using jobs.query or jobs.getQueryResults. You can even call jobs.getQueryResults on an already-completed query job, even if that query job was executed by some other means.
https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
https://cloud.google.com/bigquery/docs/reference/v2/jobs/getQueryResults
Is there a way to retrieve the query metadata within Neo4jClient which can be returned after executing a Cypher querty.
Within the Neo4j browser when making a request against the server the following kind of response is returned.
{
"results":[
{
"columns":[
],
"data":[
],
"stats":{
"contains_updates":false,
"nodes_created":0,
"nodes_deleted":0,
"properties_set":0,
"relationships_created":0,
"relationship_deleted":0,
"labels_added":0,
"labels_removed":0,
"indexes_added":0,
"indexes_removed":0,
"constraints_added":0,
"constraints_removed":0
}
}
],
"errors":[
]
}
The block I am interested in is the stats block.
A quick look at the request shows a includeStats=true flag being set but I see no inclusion of it within the neo4jclient code.
Many thanks.
Not at this time, no.
There are some stats on the IGraphClient.OperationCompleted event, but not these ones.
You are welcome to extend this event and send a pull request at https://github.com/readify/Neo4jClient/