Retrieve the newly added comments from Facebook - facebook

Giving a PostId i'm trying to retrieve all the comments attached to this post by using the graphApi. Its simple to retrieve the comments for the first time, i just keep following the next link in the paging propertie of the api response.
But to keep this list of comments up to date i need to retrieve the newly added comments. I tried using the cursor After (stored from the last retrieved page) but it's not working as expected, using the parameter since in the query doesn't work either (seems that it is not supported by the endpoints /comments).
Can please someone gives me an alternative solution?

As i said 'since' is not supported by the endpoint '/comments' because the api use cursors for the pagination (next, after and befor fields).
The use of the cursor 'after' will not work neither, because the its value is valide for a short period of time (docs link)
So my solution was to use an ordred query to get the comments
https://graph.facebook.com/v2.6/[post-id]/comments/&filter=stream&order=reverse_chronological
, i save the created_timeof the first comment as last_update_time. Then the next time i execute my code i check for each comment the time when it has been created if it's grater than the last update time i save it
while (comment.created_time > last_update_time):
comments_list.add(comment)
comment = comments.next()
if (len(comments_list)>0):
last_update_time = comments_list[0].created_time

Related

Using Smartsheet API 2.0 how to get ONLY the 'modifiedAt' property of a specific sheet

I need to get the last modified timestamp property of a sheet using Smartsheet API 2.0 (preferably Python SDK).
Ref:
https://smartsheet-platform.github.io/api-docs/
https://github.com/smartsheet-platform/smartsheet-python-sdk
Using Sheets.list_sheets I am able to get the 'modifiedAt' property (along with other properties) for all the sheets that I have access to.
Using Sheets.get_sheet(sheet_id) I get all the data (rows, columns) for the specified sheet.
How do I get only the 'modifiedAt' (it's OK if some other small properties are also present) for a specific sheet with a known sheet ID. I don't want the row, column, cell information to be present in the API response.
I wrote to Smartsheet support team and their answer served my purpose.
Thanks for contacting Smartsheet Support. In order to narrow down the
response that you're getting, you can use the exclude parameter:
http://smartsheet-platform.github.io/api-docs/#query-strings. In my
testing, I excluded all rows and columns where columnIds=0 and
rowIds=0. That left me with only the Sheet information, which includes
the modifiedAt for the sheet. You may be able to limit it further, but
the result I got from this was pretty short and sweet.
(Python SDK example)
response = ss_client.Sheets.get_sheet(MY_SHEET_ID, column_ids='0', row_ids = '0')
Using the above parameters, I was able to exclude all the sheet data and got only the metadata (which included modifiedAt property).
Basically my intention was to run a sync script periodically and store the Smartsheet data into my local db. I wanted the API response to skip the actual Sheet data (rows, columns, cells) if nothing would have changed since the last execution. Another nifty way of achieving this to use the ifVersionAfter parameter.
ifVersionAfter (optional): If version specified is still the current
sheet version, then returns an abbreviated Sheet object with only the
sheet version property. Otherwise, if the sheet has been modified,
returns the complete Sheet object. Intended to allow clients with a
cached copy to make sure they have the latest version.
last_version_fetched = 7724
response = ss_client.Sheets.get_sheet(MY_SHEET_ID, if_version_after=last_version_fetched)
The Get Sheet call will always return the content (row, column, data) from a specific sheet. While there is an 'exclude' query parameter that can filter out some properties, it does not work on the primary sheet data returned from the /sheets/{sheetId} endpoint.
The Sheets.list_sheets call seems like the easier route if you only need the modifiedAt property. I would use that one then iterate over the results until you find the matching id.

Post into Confluence table using REST API

Found many examples on simple API queries but nothing close to what i want.
I have my space key and page ID, this is my table
How can i append hyperlinks, and attach a file in cell 3 for each build using REST API.
get the page : add expand=body.storage as a query parameter to get the body.storage.value which holds the html tags. Then parse the get response to edit the specific value in the 's then when updating the page update the body.storage.value withing your json like in the example: https://docs.atlassian.com/atlassian-confluence/REST/latest-server/#content-update

How to delete only a subset of posted data in firebase

Posting data to firebase generate new items similar to the following example:
log
-K4JVL1PZUpMc0r0xYcw
-K4jVRhOeL7fH6CoNNI8
-K4Jw0Uo0gUcxZ74MWBO
I struggle to find how to e.g. delete entries that is older than x days - preferably with the REST API. Suggestions appreciated.
You can do a range query.
This technique requires you to have a timestamp property for each record.
Using orderBy and endAt you can retrieve all of the items before a specified date.
curl https://<my-firebase-app>.firebaseio.com/category/.json?orderBy="timestamp"&endAt=1449754918067
Then with the result, you can delete each individual item.

Filtering by action_target_id on Facebook Ads API

I am using the Facebook Ads API to try to filter out specific action target ids using the follwowing call:
(account-id)/reportstats?date_preset=yesterday&data_columns=["action_target_name","adgroup_id","adgroup_name","spend","actions","adgroup_objective"]&actions_group_by=["action_target_id", "action_destination"]&filters=[{"field": "action_target_id","type": "contains","value": 'insert id'}]
Every time I try to put in a specific ID, I get an empty data set back. Whenever I change the type to "not_contains", I get every piece of data returned. I've also tried the same with action_destination, but it keeps saying value needs to be numeric even though it a string.
It definitely seems like you can filter by action_target_id because when I tried to filter by something random, it told me that filter doesn't exist.
Can anyone help me please?
Unfortunately these values are nested under the actions fields of the results and filters only work on top level field values.

How to retrieve the change comment for a moment using the REST API?

I'm trying to retrieve the last change comment for a member's profile. I see how I can get the last 'moment' for a profile:
/rest-1.oauth.v1/Data/Member/[MemberID]?sel=MyLastChangeMoment
Using that moment ID I can get the last moment
/rest-1.oauth.v1/Data/Member/[MemberID]/[MomentID]
However, that moment data does not include the change comment. How can I retrieve the change comment associated with that moment?
You can retrieve the last change comment for a Member asset using the ChangeComment attribute.
Here's an example query to get the last ChangeComment that was specified for member 20:
http://localhost/versionone/rest-1.v1/Data/Member/20?sel=Name,ChangeComment