facebook JSOn API question - json

I am using JSON GRAPH API for facebook to retrieve all the post from a particular group. I can access all the post without authentication. However the problem I have is, if a particular post has more comments (like 10) then JSON outputs shows only 3 comments(not all 10). However the "Key" "Count" in JSON output gives the value as 10(meaning 10 comments for the post) but displays only 3. How to resolve this problem.
ANy help is greatly appreciated...!!!

In that json data set there is a a key named 'paging' that gives you the next and previous sets ('next' and 'previous' respectively). You can use those urls to traverse all comments.
See the section named 'Paging' in the docs here: http://developers.facebook.com/docs/api?ref=mf for more stuff (like limits and time queries)

Related

receive Excel data and turn into objects to format a JSON

I have this solution that helps me creating a Wizard to fill some data and turn into JSON, the problem now is that I have to receive a xlsx and turn specific data from it into JSON, not all the data but only the ones I want which are documented in the last link.
In this link: https://stackblitz.com/edit/xlsx-to-json I can access the excel data and turn into object (when I print document.getElementById('output').innerHTML = JSON.parse(dataString); it shows [object Object])
I want to implement this solution and automatically get the specified fields in the config.ts but can't get to work. For now, I have these in my HTML and app-component.ts
https://stackblitz.com/edit/angular-xbsxd9 (It's probably not compiling but it's to show the code only)
It wasn't quite clear what you were asking, but based on the assumption that what you are trying to do is:
Given the data in the spreadsheet that is uploaded
Use a config that holds the list of column names you want returned in the JSON when the user clicks to download
based on this, I've created a fork of your sample here -> Forked Stackbliz
what I've done is:
use the map operator on the array returned from the sheet_to_json method
Within the map, the process is looping through each key of the record (each key being a column in this case).
If a column in the row is defined in the propertymap file (config), then return it.
This approach strips out all columns you don't care about up front. so that by the time the user clicks to download the file, only the columns you want are returned. If you need to maintain the original columns, then you can move this logic somewhere more convenient for you.
I also augmented the property map a little to give you more granular control over how to format the data in the returned JSON. i.e. don't treat numbers as strings in the final output. you can use this as a template if it suites your needs for any additional formatting.
hope it helps.

Squarespace access JSON properties via URL?

I know that I can access the JSON data like so http://base-template.squarespace.com/news/?format=json-pretty. But what I want to access lets says a property on that like news.items? http://base-template.squarespace.com/news/items/?format=json-pretty throw an error. Is there a way to drill into the JSON data via the URL?
Yes, you can access a collection's items using the same format=json-pretty query parameter as you mentioned.
Do note, however, that:
The URL must exist (which in your second 'news' example is not the case)
To get a list of items from a collection, you use the format=json-pretty on the collection, the scope into items from there.
When performing this type of request via Javascript, you'll probably want to simply use format=json since the 'pretty' line breaks and indenting aren't necessary in that case.
For example, using the base-template as you have already mentioned, to get the blog items you would use: https://base-template.squarespace.com/blog?format=json-pretty. Within the JSON, you'll see an 'items' array, which is the data you're looking for (See the image below for a screenshot of this.). If that website had a "/news" collection, you could do similar.
Similarly, if you wanted to view the JSON output from a specific item, you would, for example, use: https://base-template.squarespace.com/blog/2016/7/15/most-recent-sample-blog-post?format=json-pretty

box .Net v2 API how to fetch all fields?

The Box v2 REST API appears to contain methods that return "full objects". That is, they return all the fields and properties of the object requested with one "simple" call.
When trying the official .Net SDK, it appears that if you don't specify fields by name in the "FoldersManager" or "FilesManager" (for example), you get minimal details of the objects returned.
Is there a way to make the request return all fields/properties? I realize maybe ItemsCollection is one you'd want to retrieve specifically, but the rest should really be included in one call (like the REST capability).
Thanks for any ideas!
-AJ
If no fields are specified in the request, the default fields are returned in the response (ie. what the API decides is the most commonly used fields). If a field is specified the API returns all required fields along with the specified fields (usually type, id, and etag).
There is currently no simple flag that will return all fields as this would likely be abused out of convenience. The only way to return all fields is to manually specify all of the fields you are looking for. If using any of the official SDKs, these fields names can usually be found in the object models
HTH

ElasticSearch Get Index Names and Store Size

I am attempting to capture a list of all the indexes and their sizes in a way that I could capture the information using Angular's $http service and then iterate through the information using the ng-repeat preferably with something like:
<ul ng-repeat="elsindex in elsIndexHttpResponse">
<li>{{elsindex.name}}:{{elsindex.size}}</li>
</ul>
The closest thing I have found is this:
http://localhost:9200/_cat/indices?h=index,store.size
Except:
a. its responses are not in json so easily referencing it using the ng-repeat <li> elements isn't going to work; and
b. i would like, if possible, to get the size output to reflect the same unit size (like bytes).
If this involves something complicated then I'd be grateful for pointers on where I should focus.
I am using elasticsearch v1.4.4
Many thanks
I realize this question dates already, but wanted to add my 2 cents.
http://localhost:9200/_cat/indices?h=index,store.size&bytes=kb&format=json
Would actually get you exactly what you requested:
format=json -> formats the output to json
bytes=kb -> outputs the size in kilobytes
Information regarding the size unit was retrieved from cat APIs doc
Possible values for the bytes argument
Information regarding the format was an attempt in Sense, which has some auto-completion features quite useful to detect such options.
Cheers.
Index size in bytes is included with an indices stats API call:
curl http://localhost:9200/_stats/indexing,store
For nicely formatted JSON output, append ?pretty to the end of the URL:
curl http://localhost:9200/_stats/indexing,store?pretty
See the Indices stats API documentation for additional details and related information.
Just a slight modification from above answer.
curl -X GET "localhost:9200/_cat/indices?h=index,store.size&bytes=gb?pretty"
In case you want the size of a particular index, the below API works fine on Elastic Search 7.14.
curl http://10.29.61.105:9200/employee/_stats where employee is the desired index name.

Docusign Prefilling fields with Java and XML does not appear to work

I'm trying to send an envelope from a template using the REST API. I'm using Java with XML since the Java example is given with XML only. Here:
http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromTemplate
My template is very simple. It has:
1. A data field called Material1
2. A data field called Quantity1
3. A Full Name field
4. Signature field
5. Date Signed field
Here's the screen shot:
The Java code I'm using is exactly as it appears in the API Walkthrough link that I provided above. The XML that I supply is:
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<accountId>ZZZZZZZZZZ</accountId>
<status>sent</status>
<emailSubject>DocuSign API Call - Signature request from template
</emailSubject>
<templateId>1886EC14-153E-4E05-AFF8-04F508098E60</templateId>
<templateRoles>
<templateRole>
<name>Michael</name>
<email>michael#company.com</email>
<roleName>Signer1</roleName>
<tabs>
<textTabs>
<text>
<tabLabel>\*Material1</tabLabel>
<value>MTX80HD</value>
</text>
<text>
<tabLabel>\*Quantity1</tabLabel>
<value>11</value>
</text>
</textTabs>
</tabs>
</templateRole>
</templateRoles>
</envelopeDefinition>
However the value of MTX80HD is not being prefilled in the Material1 Field, nor do I see 11 in the Quantity1.
I've read multiple posts here and followed every suggestion that I have found but still can't get the pre population to work. The Full Name and Date Sign are filled in however.
TIA
Edit 1:
OK. I converted the XML to JSON, as #ergin suggested below and the fields are still not prepopulated. So the issue must lie elsewhere and not with XML.
Here's the JSON I'm sending:
{"account":"MyAccountId","status":"sent","emailSubject":"DocuSign API Call - Test signature request from template","templateId":"1886EC14-153E-4E05-AFF8-04F508098E60","templateRoles":[{"name":"Michael","email":"michael#company.com","roleName":"Signer1","tabs":{"textTabs":[{"tabLabel":"Material1","value":"MTX80HD"}]}}]}
The URL I'm sending the above JSON to is:
https://demo.docusign.net/restapi/v2/accounts/MyAccountId/envelopes
The fields I'm trying to populate with the tabs were created on the template as Data Field widgets.
I must be missing something obvious, as I see people posting that they got it to work, eventually.
Hope to hear from anyone who has any ideas.
Thanks.
Do you have multiple tabs that are using the same tabLabel or just one? You only need the escape sequence when you have multiple, however even then you need an extra backslash (). You have this
<tabLabel>\*Material1</tabLabel>
But it should be this instead:
<tabLabel>\\*Material1</tabLabel>
However if you only have one tab with the name Material1 then don't use \\* at all.
Also, if you want to use JSON instead you can look at some of the other API walkthroughs in other languages that show JSON, or you can use the auto-generated REST API help page:
https://www.docusign.net/restapi/help