Finding the count of each reaction from a post - facebook

I want to be able to get the total amount of reactions and then split by each type of reaction. This is what I am using so far for getting the total amount of reactions and the count of likes.
me?fields=posts{reactions.summary(true),likes.summary(true)}
However, I would like for the other kind of reactions to be included as well (love, sad, hahah etc.)
When I try to query the love field I get the following debug message:
The love field does not exist on the PagePost object.
I've gone through all the node options but I can't find them.
Any help will be greatly appreciated since I am quite stuck.

Specific types of reactions can be queried using the type parameter, see https://developers.facebook.com/docs/graph-api/reference/v6.0/object/reactions#parameters
If you want to query data for multiple reactions in one request, then you will have to use the Field Aliasing syntax, otherwise you will get an error saying that your field list contained the reactions field twice. https://developers.facebook.com/docs/graph-api/aliasing-fields
So this could look something like this,
me?fields=posts{reactions.type(LOVE).summary(1).as(reacts_love),
reactions.type(LIKE).summary(1).as(reacts_like)}
(Exemplary for the two reaction types LOVE and LIKE - add the rest, by following the same format.)
The resulting data will then contain sub-structures under the keys reacts_love and reacts_like.
This might still give you some data about individual reactions - if you don’t need those, but only the summaries, you can also add .limit(0) into the above “chains” of parameters - then the data portion of these responses will always be empty.

Related

Using found set of records as basis for value list

Beginner question. I would like to have a value list display only the records in a found set.
For example, in a law firm database that has two tables, Clients and Cases, I can easily create value list that displays all cases for clients.
But that is a lot of cases to pick from, and invites user mistakes. I would like the selection from the value list to be restricted to cases matched to a particular client.
I have tried this method https://support.claris.com/s/article/Creating-conditional-Value-Lists-1503692929150?language=en_US and it works up to a point, but it requires too much entry of data and too many tables.
It seem like there ought to be a simpler method using the find function. Any help or ideas greatly appreciated.

Best way to record a prospects product interest through a hidden field when they submit a Pardot form

I would like to know the best method when it comes to recording a prospects product interest when they submit a pardot form. I do not want this to be visible to the user and I want to be sure this field won’t overwrite itself if the same prospect submits a separate form with a different interest value. Any tips on the best way to do this? (A detailed response is most appreciated, thanks!)
Look at the option "Record and display multiple responses" you can apply to a Prospect field. This will allow you to collect multiple responses over time. I am not a huge fan of this because a prior response could have been years ago, and it's potentially confusing to have a really old interest commingled with the current interest.
Another option is to have the above setting on a 'cumulative interest' PLUS a seperate 'most recent interest' field. This gives you a more nuanced data collection plus having all the history.
Hidden form fields populated with the values work well to collect and populate the values.

Do I have to loop through each 'page' of orders to get all orders in one WooComerce REST Api query?

I've built a KNIME workflow that helps me analyse (sales) data from numerous channels. In the past I used to export all orders manually and use an XSLX or CSV reader but I want to do it via WooCommerce's REST API to reduce manual labor.
I would like to be able to receive all orders up until now from a single query. So far, I only get as many as the # I fill in for &per_page=X. But if I fill in like 1000, it gives an error. This + my common sense give me the feeling I'm thinking the wrong way!
If it is not possible, is looping through all pages the second best thing?
I've managed to connect to the api via basic auth. The following query returns orders, but only 10:
I've tried increasing the number per_page but I do not think this is the right way to get all orders in one table.
https://XXXX.nl/wp-json/wc/v3/orders?consumer_key=XXXX&consumer_secret=XXXX
My current mindset would like to be able to receive all orders up until now from a single query. But it personally also feels like that this is not the common way to do it. Is looping through all pages the second best thing?
Thanks in advance for your responses. I am more of a data analist than a data engineer or scientist and I hope your answers will help me towards my goal of being more of a scientist :)
It's possible by passing params "per_page" with the request
per_page integer Maximum number of items to be returned in result set. Default is 10.
Try -1 as the value
https://woocommerce.github.io/woocommerce-rest-api-docs/?php#list-all-orders

how to avoid redundent in Yahoo answer api

I have a question about Yahoo answer api. I plan to use (questionSearch, getByCategory, getQuestion, getByUser). For example I used getByCategory to query. Each time I call the function, I can query max 50 questions. However, there are a lot of same questions which have been queried in previous time. So How can I remove this redundent ?
The API doesn't track what it has returned to you previously as its stateless.
This leaves you with two options that I can think of.
1) After you get your data back filter out what you already have. This requires you checking what is displayed and then not displaying duplicated items.
2) Store all ID's you have showing in a list, then adjust your YQL Query so that it provides that list of ID's as ones not to turn. Like:
select * from answers.getbycategory where category_id=2115500137 and type="resolved" and id not in ('20140216060544AA0tCLE', '20140215125452AAcNRTq', '20140215124804AAC1cQl');
The downside of this, is that it could effect performance since your YQL queries will start to take longer and longer to return.

Mongo pagination

I have a use case where I need to get list of Objects from mongo based off a query. But, to improve performance I am adding Pagination.
So, for first call I get list of say 10 Objects, in next I need 10 more. But I cannot use offset and pageSize directly because the first 10 objects displayed on the page may have been modified [ deleted ].
Solution is to find Object Id of last object passed and retrieve next 10 objects after that ObjectId.
Please help how to efficiently do it using Morphia mongo.
Using morphia you can do this by the following command.
datastore.find(YourClass.class).field(id).smallerThan(lastId).limit(10).order("-ts");
Since you are querying for retrieving the items after the last retrieved id, you won't be bothered to deal with deleted items.
One thing I have thought up of is that you will have the same problem as with using skip() here unless you intend to change how your interface works.
Using ranged queries like this demands that you use a different kind of interface since it is must harder to detect now exactly what page you are on and how many pages exist in the future, especially if you are doing this to avoid problems with conventional paging.
The default type of interface to arise from this type of paging is merely a infinitely scrolling page, think of YouTube video comments or Facebook wall feed or even Google+. There is no physical pagination or "pages", instead you have a get more button.
This is the type of interface you will need to use to get ranged paging working better.
As for the query #cubbuk gives a good example:
datastore.find(YourClass.class).field(id).smallerThan(lastId).limit(10).order("-ts");
Except it should be greaterThan(lastId) since you want to find everything above that last _id. I would also sort by _id unless you make your OjbectIds sometime before you insert a record, if this is the case then you can use a specific timestamp set on insert instead.