I have been using facebook's graph api. Now I got to know that there will not be a count field in "comment" object in the returned JSON. Now we have to make an extra effort for finding the total comments on the post which I do not want if I know the default number of comments put by the API in the JSON.
If I have the default number then I get to know whether I have to make a separate call for finding the total number of comments.
So, could anyone tell me the default comment count value?
There is a way to get count of comments back.
It's example from developers.facebook.com/tools/explorer
SocialMediaClubMoscow?fields=feed.fields(comments.limit(1).filter(toplevel),message,likes,shares,from)
},
"summary": {
"order": "chronological",
"total_count": 12
}
total_count - is count of all comments
Related topic:
Removing 'count' from 'comments' Graph API connection
Related
Using the Facebook Marketing API (Graph API), I use the following (simplified for brevity) query:
act_xxxxxx/insights?level=adset&fields=date_start,date_stop,clicks,adset_name
This gives me a result like this:
{
"data": [
{
"date_start": "2019-01-01",
"date_stop": "2019-01-30",
"clicks": "999",
"adset_name": "Awesome Adset"
}
] //paging info removed, not relevant
}
For each node in data, I would like to include some properties from the adset, like end_time,start_time,lifetime_budget,daily_budget.
I have looked into expanding fields, but there does not seem to be an adset field I can expand on here.
Is there a way to include adset fields like lifetime_budget, so I can get the results in one go?
Right now, query adsets separately and join afterwards, but I think there must be a way to get it in one resultset.
You could query adsets and ask for all the fields you need adding with the parenthesis notation each kind of params you need, as example, for ask about all the adsets with budgets info and bid strategy of an adAccount with insights with specified metrics, you can use the following:
act_XXXX/adsets?fields=insights{clicks,spend,cpc},lifetime_budget,daily_budget,name,start_time,end_time
Hope this help
I'm trying to filter the list of users returned from Directory.Users.List, and want to use the creationTime value in the filter. According to this:
Search for users
...you can use Date fields in comparisons, however when I try something like:
creationTime>=2016-06-30 (or the same value quoted)
...I get:
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Input: creationTime>=2016-06-30",
"reason" : "invalid"
} ],
"message" : "Invalid Input: creationTime>=2016-06-30"
}
The message isn't particularly helpful - is this a syntax issue with the query, or is it the case that the field isn't available for query (it isn't listed in that article, but it is part of the JSON response)?
The article specifies the format for Date field queries, however this field also includes a time component, so I tried to also replicate the exact format that shows in the JSON, with the same result.
Also, same result in the Try it! section of the Users reference page.
Also also, tried using a numeric value (Date.getTime(), in effect) - same error.
Thanks...
P.S. Interestingly, Google does document how to search on date fields for Chromebooks, and it's entirely different than they imply for users. I still can't use creationTime with this, but it does work for Chromebooks. The other part of this is that it refers to fields that aren't documented, and why I try to use the documented field (e.g. lastSync vs. sync), it fails with the same message. This whole thing seems half-baked.
View Chrome device information
Only the fields listed in the table are searchable via the users.list search.
A workaround (I don't know if this is suitable for you) may be to push the data you want to use in a search into custom user fields. These fields are searchable.
Let's imagine I have three classes: User,Post, Comment. Standard actions — user can create posts and write comments to these posts. So we have the situation depicted below:
I need to perform these three queries very quickly:
Get all comments for a post
Get all comments for a user
Get post for a comment
And it looks like it isn't possible even if I will use partitioning. At least not with a single reliable dictionary. Probably I need several dictionaries for different queries. Am I correct?
I'm working on the same thing! First of all: My schema is a bit different. I have a user, a topic and a comment. The topic is just a class with a list of comment ids(IEnumerable long), nothing more. The first comment is the post.
Oh, really first of all, little warning: I'm just beginning with Service Fabric, so I might be doing it wrong ;)
The user is not relevant for me. I just store the userid on the comment. When retrieving a list of comments I get the users from the stateful users service. Or I will store the users name in the comment directly, not sure yet.
So that leaves me with topics and comments. First I thought 'lets create a Stateful TopicService and a Stateful CommentService'. But then I realised that for every topic I load I need to call the CommentService for each comment to get the comments.
So I created a TopicService which handles 2 IReliableDictionaries: topics and comments.
Whenever a comment is posted I use the TopicId as the partitionkey and in that partition the comment is stored. So NOT using the commentid !! This way all the comments for a specific topic are in the same partition.
When loading a topic with all the comments I use the TopicId as the partitionkey again, get the topic from the reliabledictionary for the topics and loop the list of comment ids in the reliabledictionary for the comments. Not sure if it helps, but my GetComments looks like this:
var topics = await this.StateManager.GetOrAddAsync<IReliableDictionary<long, TopicModel>>("topics");
var comments = await this.StateManager.GetOrAddAsync<IReliableDictionary<long, CommentModel>>("comments");
List<CommentModel> result = new List<CommentModel>();
using (var tx = this.StateManager.CreateTransaction())
{
ConditionalValue<TopicModel> topic = await topics.TryGetValueAsync(tx, topicid);
if(topic.HasValue)
{
foreach(long commentid in topic.Value.CommentsInternal)
{
ConditionalValue<CommentModel> comment = await comments.TryGetValueAsync(tx, commentid);
if (comment.HasValue)
result.Add(comment.Value);
}
}
await tx.CommitAsync();
}
return result;
I'm not done yet, the method some more work.
Perhaps this helps you :)
edit: ow, there is a disadvantage! When you want to load a single comment by its id, you need to provide the topicid. So my CommentModel class has a CommentId and a TopicId property.
I'm trying to create some social dashboard and therefore I want to retrieve my posts from my page. When I use this one to fetch my posts, it doesn't return me all the information I need (e.g 'picture', 'full_picture', 'attachments')
$user_posts = $facebook->api('/me/posts', 'GET');
print_r($user_posts);
But when I try next one, it still doesn't return me my required information:
$user_posts = $facebook->api('/me/posts?{created_time,id,message,full_picture,picture,attachments{url,subattachments},likes{name},comments{from,message,comment_count,user_likes,likes{name}}}', 'GET');
print_r($user_posts);
Anyone ideas??
I know that this has been asked a long time ago, but maybe useful for someone:
After - me/posts? - you need to make sure to put fields= and then a list of fields required.
So this would be:
$user_posts = $facebook->api('/me/posts?fields={created_time,id,message,full_picture,picture,attachments{url,subattachments},likes{name},comments{from,message,comment_count,user_likes,likes{name}}}', 'GET');
print_r($user_posts);
When using Amazon's web service to get any product's information, is there a direct way to get the Average Customer Rating (1-5 stars)? Here are the parameters I'm using:
Service=AWSECommerceService
Version=2011-08-01
Operation=ItemSearch
SearchIndex=Books
Title=A Game of Thrones
ResponseGroup=Large
I would expect it to have a customer rating of 4.5 and total reviews of 2177. But instead I get the following in the response.
<CustomerReviews><IFrameURL>http://www.amazon.com/reviews/iframe?...</IFrameURL></CustomerReviews>
Is there a way to get the overall customer rating, besides for reading the <IFrameURL/> value, making another HTTP request for that page of reviews, and then screen scraping the HTML? That approach is fragile since Amazon could easily change the reviews page structure which would bust my application.
You can scrape from here. Just replace the asin with what you need.
http://www.amazon.com/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=B000P0ZSHK
As far as i know, Amazon changed it's API so its not possible anymore to get the reviewrank information. If you check this Link the note sais:
As of November 8, 2010, only the iframe URL is returned in the request
content.
However, testing with the params you used to get the Iframe it seems that now even the Iframe dosn't work anymore. Thus, even in the latest API Reference in the chapter "Motivating Customers to Buy" the part "reviews" is compleatly missing.
However: Since i'm also very interested if its still possible somehow to get the reviewrank information - maybe even not using amazon API but a competitors API to get review rank informations - i'll set up a bounty if anybody can provide something helpful on that. Bounty will be set in this topic in two days.
You can grab the iframe review url and then use css to position it so only the star rating shows. It's not ideal since you're not getting raw data, but it's an easy way to add the rating to your page.
Sample of this in action - http://spamtech.co.uk/positioning-content-inside-an-iframe/
Here is a VBS script that would scrape the rating. Paste the code below to a text file, rename it to Test.vbs and double click to run on Windows.
sAsin = InputBox("What is your ASIN?", "Amazon Standard Identification Number (ASIN)", "B000P0ZSHK")
if sAsin <> "" Then
sHtml = SendData("http://www.amazon.com/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=" & sAsin)
sRating = ExtractHtml(sHtml, "<span class=""a-size-base a-color-secondary"">(.*?)<\/span>")
sReviews = ExtractHtml(sHtml, "<a class=""a-size-small a-link-emphasis"".*?>.*?See all(.*?)<\/a>")
MsgBox sRating & vbCrLf & sReviews
End If
Function ExtractHtml(sHtml,sPattern)
Set oRegExp = New RegExp
oRegExp.Pattern = sPattern
oRegExp.IgnoreCase = True
Set oMatch = oRegExp.Execute(sHtml)
If oMatch.Count = 1 Then
ExtractHtml = Trim(oMatch.Item(0).SubMatches(0))
End If
End Function
Function SendData(sUrl)
Dim oHttp 'As XMLHTTP30
Set oHttp = CreateObject("Msxml2.XMLHTTP")
oHttp.open "GET", sUrl, False
oHttp.send
SendData = Replace(oHttp.responseText,vbLf,"")
End Function
Amazon has completely removed support for accessing rating/review information from their API. The docs mention a Response Element in the form of customer rating, but that doesn't work either.
Google shopping using Viewpoints for some reviews and other sources
This is not possible from PAPI. You either need to scrape it by yourself, or you can use other free/cheaper third-party alternatives for that.
We use the amazon-price API from RapidAPI for this, it supports price/rating/review count fetching for up to 1000 products in a single request.