Aggregation of different actions - action

In my application I'd like to send different actions:
read article
watch video
view gallery
How can I aggregate all these actions? I can get actions by type of an action:
"namespace:action_type" (graph API). How can I get all actions done by a user?

You could embed the Activity Plugin, and specify the actions param with a CSV list of all the actions you'd like it to show - see https://developers.facebook.com/docs/reference/plugins/activity2/. This would them show the actions of those types performed by the viewing users friends on your domain.
actions="news.reads,namespace:action1,namespace:action2"
Its not possible to make a single API call to get all the actions by the user, or all the actions by the user in your app - you must make one call per action type. You can use the Batch API to make multiple calls at once: https://developers.facebook.com/docs/reference/api/batch/

Related

How to add built-in test event to lambda function?

I have several lambda functions in my project.
For each function I have an event file that is used for local test purposes.
I wonder to know how can I attached these events files to my lambda function inside the aws-console as test event, so I will not need to create a new event each time after code deployment.
Seems like my answer involves with template.yaml file but I couldn't find the answer over the web.
This is not possible.
You cannot add or seed pre-existing 'test events' for a Lambda function - they're meant to just be an easy way of invoking your Lambda from within the console itself.
You will have to recreate them manually unless you are using shareable test events.
You might be looking for Shareable Test Events.
Shareable test events are test events that you can share with other AWS Identity and Access Management (IAM) users in the same AWS account. You can edit other users' shareable test events and invoke your function with them.
To create a shareable test event
Open the Functions page of the Lambda console.
Choose the name of the function that you want to test.
Choose the Test tab.
Choose a Template.
Enter a Name for the test.
In the text entry box, enter the JSON test event.
Under Event sharing settings, choose Shareable.
Choose Save changes.

Can I create temporary users through Amazon Cognito?

Does Amazon Cognito support temporary users? For my use case, I want to be able to give access to external users, but limited to a time period (e.g. 7 days)
Currently, my solution is something like:
Create User in User Group
Schedule cron job to run in x days
Job will disable/remove User from User Group
This all seems to be quite manual and I was hoping Cognito provides something similar automatically.
Unfortunately there is no functionality used to automate this workflow so you would need to devise your own solution.
I would suggest the below approach to handling this:
Create a Lambda function that is able to post process a user sign up. This Lambda function would create a CloudWatch Event with a schedule for 7 days in the future. Using the SDK you would create the event and assign a target of another Lambda function. When you specify the target in the put_targets function use the Input parameter to pass in your own JSON, this should contain a metadata item related to the user.
You would then create a post confirmation Lambda trigger which would trigger the Lambda you created in the above step. This would allow you to schedule an event every time a user signs up.
Finally create the target Lambda for the CloudWatch event, this will access the input passed in from the trigger and can use the AWS SDK to perform any cognito functions you might want to use such as deleting the user.
The benefit to using these services rather a cron, is that you can perform the most optimal processing only when it is required. If you have many users in this temporary group you would need to loop through every user and compare if its ready to be removed for a one time script (and perhaps sometimes never remove users).
My solution for this is the following: Instead of creating a post confirmation lambda trigger you can also create a pre authentication lambda trigger. This trigger will check for the user attribute "valid_until" which contains a unix timestamp. The pre authentication lambda trigger will only let the user in if the value of the "valid_until" attribute is in the future. Main benefit of this solution is that you don't need any cron-jobs.

Facebook Graph Api search events

I thought it was a simple thing but I was wrong, I would like to have the list of public events of a page (such as the redbull)
I tried this but without luck:
/14226545351/events
Also I would like to know if it was possible to search for events by keyword, I tried this but without luck:
/search?q=run&type=event
I generated an access token, with the right permissions (I think) but in both cases I read
{
"data": [
]
}
You can no longer use the /search endpoint with the following object
types:
event
group
page
user
Source: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Event Search is not possible anymore, and the Events API in general is not possible as of now:
...apps currently accessing Events and Groups APIs will lose access today.
Source: https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/
It is currently not possible to query event data using the facebook api https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/

Querying Open Graph objects and actions

I've created a few actions and object types for my application. For this question's purpose, let's assume I have an myapp:book custom type (where myapp is my application's namespace and book is the custom type) and a myapp:read action.
Is is possible answer any of the following queries using Facebook's Graph API (or any other FB API)?
List all objects of type myapp:book. By that, I mean retrieve a list all pages that FB's scraper has stored which have an go:type of myapp:book.
List all actions that involve objects of type myapp:book.
List all read actions that occurred in my app. By that, I mean retrieve a list of all actions that were posted to FB which have an action_type of myapp:read
As far as I'm aware: no, no and no
Your own databases should have all of that information already though, depending on how you've implemented the app, certainly the first two if not necessarily the third
You can retrieve, for a given user, the list of actions of a particular type, but not 'all actions' or 'across all users'

How to get all the Open Graph Beta actions generated by an app?

It is already possible to get all actions for custom app actions and objects:
https://graph.facebook.com/me/{appNameSpace}:{action}/{object}
This will list all the actions generated by an app, but only for a given user...
How do I get all the actions generated by an app (for all its users)?
I've tried this request with an app access token :
https://graph.facebook.com/{appId}/{appNameSpace}:{action}/{object}
But it does not work...
I was also looking for an activities or actions FQL table, since each action has an id, they should be accessible somewhere.
Any suggestions?
AFAIK there is no way to get all actions published by application via OpenGraph, but your application creates those actions, why just not record results of this operation?
Then you create action you should get response like this:
{
id: “{action-instance-id}”
}
Later you may read this action:
GET https://graph.facebook.com/{action-instance-id}
You for sure may benefit from doing request to get multiple actions like this:
GET https://graph.facebook.com/?ids={action-id1},{action-id2},{action-idn}
And even batch those requests