Instagram API and Pagination - api

I can't get all images using Instagram API, Pagination seems to be working somehow different and I can't understand it yet
I use request:
https://api.instagram.com/v1/users/self/media/recent?access_token=TOKEN
and can get first 20 photos:
...
{
"attribution": null,
"tags": [
"beautiful",
"instalife",
"picoftheday",
"beauty",
"instalike",
"gf",
"traveling",
"instatravel",
"vsco",
"tourism",
"\u0438\u0441\u043f\u0430\u043d\u0438\u044f",
"travelphoto",
"vscogood",
"instafollow",
"travel",
"\u0433\u0440\u0430\u043d\u0430\u0434\u0430",
"amazing",
"vscocam",
"followme",
"photooftheday"
],
"type": "image",
"location": null,
"comments": {
"count": 1
},
"filter": "Normal",
"created_time": "1442825564",
"link": "https:\/\/instagram.com\/p\/74vm3GOCEn\/",
"likes": {
"count": 18
},
"images": {
"low_resolution": {
"url": "https:\/\/scontent.cdninstagram.com\/hphotos-xap1\/t51.2885-15\/s320x320\/e15\/11934647_531283580370186_1131008999_n.jpg",
"width": 320,
"height": 320
},
"thumbnail": {
"url": "https:\/\/scontent.cdninstagram.com\/hphotos-xap1\/t51.2885-15\/s150x150\/e15\/11934647_531283580370186_1131008999_n.jpg",
"width": 150,
"height": 150
},
"standard_resolution": {
"url": "https:\/\/scontent.cdninstagram.com\/hphotos-xap1\/t51.2885-15\/e15\/11934647_531283580370186_1131008999_n.jpg",
"width": 612,
"height": 612
}
},
"users_in_photo": [
],
"caption": {
"created_time": "1442825564",
"text": "#\u0413\u0440\u0430\u043d\u0430\u0434\u0430 #\u0418\u0441\u043f\u0430\u043d\u0438\u044f #photooftheday #picoftheday #instalike #followme #vscogood #vscocam #vsco #instafollow #travel #traveling #instatravel #instalife #tourism #gf #beauty #beautiful #amazing #travelphoto",
"from": {
"username": "solotravel_me",
"profile_picture": "https:\/\/igcdn-photos-h-a.akamaihd.net\/hphotos-ak-xaf1\/t51.2885-19\/11282631_115839268762391_863189534_a.jpg",
"id": "736938591",
"full_name": "and"
},
"id": "1078821495951073761"
},
"user_has_liked": false,
"id": "1078821489441513767_736938591",
"user": {
"username": "solotravel_me",
"profile_picture": "https:\/\/igcdn-photos-h-a.akamaihd.net\/hphotos-ak-xaf1\/t51.2885-19\/11282631_115839268762391_863189534_a.jpg",
"id": "736938591",
"full_name": "and"
}
}
...
after that I'm trying use max_id parameter, but I'm not sure which ID I need to use
I tried id of the photo, photo_user id, I even tried timestamp (found this idea on some forum), but every time I receive only first 20 photos
example:
https://api.instagram.com/v1/users/self/media/recent?access_token=TOKEN&max_id=1078821495951073761

I was having the same problem with the empty pagination object while the account actually had more photos.
And just to make things clear here. This question is answered in the comments of the origial question.
There is nothing in the pagination object because the app is in sandbox mode and app's in sandbox mode never returns more than 20 posts(photos).

Use this API for getting all posts of the user:
https://i.instagram.com/api/v1/feed/user/{user_id}
For pagination, the parameter name is max_id
Pass max_id which you have returned in this API's response.
Hope this helps !!

Related

Adobe Analytics - how to get report API 2.0 to get multi-level breakdown data using Java

I need help in getting adobe-analytics data when multiple IDs are passed for multi-level breakdown using API 2.0.
I am getting first level data for V124 ----
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/event113",
"sort": "desc"
}
]
},
"dimension": "variables/evar124",
but i want to use IDs returned in above call response to in second level breakdown of v124 to get v125 as---
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/event113",
"sort": "desc",
"filters": [
"0"
]
}
],
"metricFilters": [
{
"id": "0",
"type": "breakdown",
"dimension": "variables/evar124",
"itemId": "2629267831"
},
{
"id": "1",
"type": "breakdown",
"dimension": "variables/evar124",
"itemId": "2629267832"
}
]
},
"dimension": "variables/evar125",
This always returns data only for 2629267831 ID and not 2629267832.
I want to get data for thousands of IDs (returned from first API call) in a single API call. What am i doing wrong?

Get all API fields definitions from Podio application

Responses from Podio API returns an JSON array of items with a fields property. Each field carries its values and its config.
For example a category field for the Gender:
{
"type": "category",
"field_id": 219922852,
"label": "Gender",
"values": [
{
"value": {
"status": "active",
"text": "Prefer not to say",
"id": 3,
"color": "F7F0C5"
}
}
],
"config": {
"settings": {
"multiple": true,
"options": [
{
"status": "active",
"text": "Male",
"id": 1,
"color": "DCEBD8"
},
{
"status": "active",
"text": "Female",
"id": 2,
"color": "F7F0C5"
},
{
"status": "active",
"text": "Prefer not to say",
"id": 3,
"color": "F7F0C5"
}
],
"display": "inline"
},
"mapping": null,
"label": "Gender"
},
"external_id": "gender"
},
How can I fetch the config without having to query a specific item?
Is there a way to get every field in the response? Because if the queried item does not have a field value set, Podio doesn't return it in the response.
I would like to get the field config for ALL the fields. If possible, with a single API request. In particular I am interested in all the possible values (in case of Category or Relationship fields) so that I could match them with local values I have.
This way I can use the field structure to programmatically map some local values to the format required by the Podio API; and then generate a fields payload that to update/create Podio items via an API calls.
You can request the Podio Get App method to get the app configuration.
Podio Doc Ref: https://developers.podio.com/doc/applications/get-app-22349

Apostrophe CMS API Create image from attachment

I have uploaded a png as per https://github.com/apostrophecms/apostrophe-headless#attachment-fields and I get back the following;
{"_id":"cjlexm6ul000j7ewxnjnse382",
"group":"images",
"createdAt":"2018-08-29T09:22:20.817Z",
"name":"sample1",
"title":"sample1",
"extension":"png",
"type":"attachment",
"docIds":[],
"trashDocIds":[],
"length":226119,
"md5":"3e150a6013f8ea2ffacbbe5a5122a668",
"width":1712,
"height":2537,
"portrait":true,
"ownerId":"cjlcqq0bw000e4qwxpx2cm75u"
}
All good but am having issues with turning this into an image. I have tried to add this repose to the POST request as per https://github.com/apostrophecms/apostrophe-headless#working-with-apostrophe-images-and-apostrophe-files
{
"title": "sample1",
"slug": "sample1",
"attachment": {
"_id": "cjlexm6ul000j7ewxnjnse382",
"group": "images",
"createdAt": "2018-08-29T09:22:20.817Z",
"name": "sample1",
"title": "sample1",
"extension": "png",
"type": "attachment",
"docIds": [],
"trashDocIds": [],
"length": 226119,
"md5": "3e150a6013f8ea2ffacbbe5a5122a668",
"width": 1712,
"height": 2537,
"portrait": true,
"ownerId": "cjlcqq0bw000e4qwxpx2cm75u"
}
}
I am getting back a
SyntaxError: Unexpected token " in JSON at position 0
on the server...
Any other ideas I can try?

“additional properties not defined” error in API call of Survey Monkey

I'm trying to use the create question endpoint of the Survey Monkey API. It is sending back following error:
{
"error": {
"docs": "https://developer.surveymonkey.com/api/v3/#error-codes",
"message": "additional properties not defined by 'properties' are not allowed in field '_data'",
"id": "1002",
"name": "Bad Request",
"http_status_code": 400
}
}
I'm able to do successfully use all other API endpoints and have a valid API key and OAuth token.
Here's an example JSON body that I'm sending to: https://api.surveymonkey.net/v3/surveys/{survey_id}/pages/{page_id}/questions?api_key=apikeyhere
{
"headings": [
{
"heading": "A question about primates",
"random_assignment": {
"percent": 50,
"position": 1
}
},
{
"heading": "A question about primates phrased slightly differently.",
"random_assignment": {
"percent": 50,
"position": 2
}
}
],
"family": "open_ended",
"subtype": "single",
"position": 1,
"sorting": {
"type": "textasc",
"ignore_last": true
},
"required": {
"text": "This question is required!",
"type": "at_least",
"amount": "1"
},
"validation": {
"type": "integer",
"text": "Validation has failed!",
"min": 20,
"max": 30
},
"forced_ranking": true
}
Any idea what might be causing the error? It seems like all fields are correctly named and where they're supposed to be, so I'm not sure what the problem is.
The field forced_ranking is not allowed for family=open_ended.
The example in the documentation at https://developer.surveymonkey.com/api/v3/#surveys-id-pages-id-questions is incorrect, we'll fix it.
Also, sorting is not available for open_ended questions as there is no choices to have shown sorted.
Also for required only validation type all seems to work. So the following payload should work:
{
"headings": [
{
"heading": "A question about primates",
"random_assignment": {
"percent": 50,
"position": 1
}
},
{
"heading": "A question about primates phrased slightly differently.",
"random_assignment": {
"percent": 50,
"position": 2
}
}
],
"family": "open_ended",
"subtype": "single",
"position": 1,
"required": {
"text": "This question is required!",
"type": "all",
"amount": "0"
},
"validation": {
"type": "integer",
"text": "Validation has failed!",
"min": 20,
"max": 30
}
}
We'll fix the documentation to make it more clear. You can see formats for specific question types here: https://developer.surveymonkey.com/api/v3/#formatting-question-types

How to get number of googleplus page followers?

is there actually a possibility to get the number of followers of my googleplus-page. the following script - which I found here in an earlier post - doesn't work (no output):
$google_api_key = 'XYZXYZXYZXYZXYZXYZ';
$page_id = 'MYNUMERICPAGEID';
$data = #file_get_contents("https://www.googleapis.com/plus/v1/people/$page_id?key=$google_api_key");
$data = json_decode($data, true);
echo $data['plusOneCount'];
thank you!
There could be a few things wrong:
Don't have an updated project on the Developer Console.
Didn't enable the API for that project.
Are past thresholds/quotas.
Try the following:
Login to your Google Developers Console
You'll need a project.
If you don't have a project, create one.
Enable "Google Plus API" on that project.
Confirm usage/quotes are within tolerance and you haven't gone past.
From there, your call should work as normal:
GET https://www.googleapis.com/plus/v1/people/{USER_ID}?key={YOUR_API_KEY}
In my case, I'm querying Google's's page, so {USER_ID} = 116899029375914044550. I can then see the plusOneCount:
{
"kind": "plus#person",
"etag": "\"RqKWnRU4WW46-6W3rWhLR9iFZQM/bTf-sq_Sg3fLAFijixPfjtKM5f8\"",
"urls": [
{
"value": "http://www.google.com",
"type": "website",
"label": "www.google.com"
},
{
"value": "http://www.google.com/support/",
"type": "other",
"label": "Google Help"
},
{
"value": "http://googleblog.blogspot.com/",
"type": "other",
"label": "Official Blog"
},
{
"value": "http://twitter.com/#!/google",
"type": "other",
"label": "#google"
},
{
"value": "http://www.google.com/about/corporate/company/",
"type": "other",
"label": "Company Info"
},
{
"value": "http://www.google.com/press/",
"type": "other",
"label": "News"
},
{
"value": "http://www.google.com/press/google-directory.html",
"type": "other",
"label": "More Google pages"
}
],
"objectType": "page",
"id": "116899029375914044550",
"displayName": "Google",
"tagline": "News and updates on Google's products, technology and more",
"aboutMe": "<p>Welcome to Google's official page. Here, you'll find product news and announcements, company updates, glimpses into what it's like to work at Google, discussions on technology and the web, and much more. </p><p><span>Given the volume of feedback we receive here, we may not be able to respond individually to every comment and we're not able to provide product support (if you're having product issues, please visit our Help Center). Rest assured we're paying attention, and we're always eager to hear from you.</span></p>",
"url": "https://plus.google.com/+google",
"image": {
"url": "https://lh4.googleusercontent.com/-v0soe-ievYE/AAAAAAAAAAI/AAAAAAAC9wQ/JD8tdz3bFTM/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"plusOneCount": 10757884,
"circledByCount": 7692912,
"verified": true,
"cover": {
"layout": "banner",
"coverPhoto": {
"url": "https://lh4.googleusercontent.com/-PLPoXvnN0XI/UTdr4xTtuHI/AAAAAAAA_1U/p1n_Za3BZUg/s630-fcrop64=1,00000000fe06fe97/g_plus_background.png",
"height": 528,
"width": 940
},
"coverInfo": {
"topImageOffset": 0,
"leftImageOffset": 0
}
}
}