Facebook Graph API - or - facebook-graph-api

Is it possible to give OR filters?
Let's say I do an HTTP GET request, the below will yield an AND filter, where both criteria must be satisfied. Is it possible to change it to OR filter?
'filtering':
"[{'field':'ad.impressions','operator':'GREATER_THAN','value':0},
{'field':'ad.effective_status','operator':'IN','value':['ACTIVE', 'PAUSED']}]"
Couldn't find a single example.
https://developers.facebook.com/docs/marketing-api/reference/ad-rule-filters/
Another way to frame the question is basically how to add more filters to e.g. below, with OR criteria.
How to further filter Facebook Graph API query on Graph API Explorer for my ad account?
/act_<yourAdAccount>/insights
?level=campaign
&fields=actions,spend
&time_increment=all_days
&time_range={'since':'2017-07-07','until':'2017-12-12'}
&filtering=[{field: "action_type",operator:"IN", value: ['mobile_app_install']}]
&use_account_attribution_setting=true

Multiple filters work only as there would be "AND" operator between them. Some desired results can be achieved by "IN" operator or batch requests.

Related

Facebook graph api get posts after a certain post id

I am using facebook graph api where I periodically call: https://graph.facebook.com/cnn/posts?access_token=accesstoken
I don't want to get repeat posts the second time I make the call so I would like to filter the call to get anything after either a certain post Id or after a created_time. Is this possible?
I have tried using date_range= but it did not work plus it only allowed me to search by date but not time.
Use timebased paging: https://developers.facebook.com/docs/graph-api/using-graph-api/#paging
The correct parameter would be since and until. Just store the timestamp of the last post and use it in your next call.

aws identity pool filter list users api on multiple conditions

Is there a way to filter the result from list users api on multiple conditions. I want to get list of all users who have usernames from a list
import boto3
client = boto3.client('cognito-idp')
client.list_users(UserPoolId='us-east-1_123456789', AttributesToGet=['email'], Filter="username =\"user_name_1\"")
the above code returns me only one username. Now if I want to get the same information for multiple usernames I cant seem to find a way to do it.
ex:
import boto3
usernames=['user_id1','user_id2']
client = boto3.client('cognito-idp')
client.list_users(UserPoolId='us-east-1_123456789', AttributesToGet=['email'], Filter="username =usernames")
Unfortunately not: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html#API_ListUsers_RequestSyntax
You can only filter by strict equality or starts-with; no wildcards or arrays.
That said, ListUsers does not seem to have an specific api-calling limit, so you would be able to call it multiple times in quick succession until you had processed all the usernames.
client.list_users() does have a limit of 60 users and this function is not pageable.
I faced a similar problem and created the filter-value that included element i of the list and contained the entire filter expression ahead of the actual function so that I was able to call that filter value within the function.
In the end, I looped over the filter-value that would adopt the new value of the lists element i.

How to build query form to request AWS CloudSearch?

I have a SearchDomain on AWS CloudSearch. I know all the defined facets names.
I would like to build a web query form to use it, but I want to add my categories values (facets) on the side, like it is done on Amazon webstore
The only way I have to get facets values is to make a query (params query) and in the answer will contain facets linked to my query results.
Is there a way to fetch all the facet.FIELD possible values to build the query form ?
If not (as read here), how to design a form using facets ?
You could also use the matchall keyword in a structured query. Also, since you don't need the results you can pass size=0 so you only get the facets which will reduce latency.
/2013-01-01/search?q=matchall&q.parser=structured&size=0&facet.field={sort:'count',size:100}

Amazon api searching Streaming Video

Ok so I am trying to search Amazon through the api for movie or tv titles. I simply want to get back the list that would include if it is available, Price, if its available on prime.
The query I have works with some issues.
By specifing a searchindex of "video" it returns results for ordering the physical dics. I only want streaming results. I have looked and streaming is not a valid search index. Is there any way to do this?
I guess basically I just want to return if it available in streaming and if it is.. is it also available on prime.

REST and Filtering records

I currently have a .NET method that looks like this - GetUsers(Filter filter) and this is invoked from the client by sending a SOAP request. As you can probably guess, it takes a bunch of filters and returns a list of users that match those filters. The filters aren't too complicated, they're basically just a set of from date, to date, age, sex etc. and the set of filters I have at any point is static.
I was wondering what the RESTful way of doing this was. I'm guessing I'll have a Users resource. Will it be something like GET /Users?fromDate=11-1-2011&toDate=11-2-2011&age=&sex=M ? Is there a way to pass it a Filter without having to convert it into individual attributes?
I'm consuming this service from a mobile client, so I think the overhead of an extra request that actually creates a filter: POST filters is bad UX. Even if we do this, what does POST filters even mean? Is that supposed to create a filter record in the database? How would the server keep track of the filter that was just created if my sequence of requests is as follows?
POST /filters -- returns a filter
{
"from-date" : "11-1-2011",
"to-date" : "11-2-2011",
"age" : "",
"sex" : "M"
}
GET /Users?filter=filter_id
Apologies if the request came off as being a little confused. I am.
Thanks,
Teja
We are doing it just like you had it
GET /Users?fromDate=11-1-2011&toDate=11-2-2011&age=&sex=M
We have 9 querystring values.
I don't see any problem with that
The way I handle it is I do a POST with the body containing the parameters and then I return a redirect to a GET. What the GET URL looks like is completely up to the server. If you want to convert the filter into separate query params you can, or if you want to persist a filter and then add a query param that points to the saved filter that's ok too. The advantage is that you can change your mind at any time and the client doesn't care.
Also, because you are doing a GET you can take advantage of caching which should more than make up for doing the extra retquest.