Upload photos to Facebook Sales group album with graph API, using the Source field and not URL - facebook-graph-api

Is there a way to create an album to the SALES groups in Facebook ? when I use the graph API explorer to fetch the user's groups it only brings back the user groups and not the sales groups he / she is part of
Command I used is get > v2.7 > me/groups and it returns
{
"data": [
{
"name": "Shadow Creek Columbus Indiana",
"privacy": "SECRET",
"id": "647651662006143"
}
],
"paging": {
"cursors": {
"before": "NjQ3NjUxNjYyMDA2MTQz",
"after": "NjQ3NjUxNjYyMDA2MTQz"
}
}
}
My second question is, if I were to create an album in the above group and add photos to it using the URL I am able to, however I have a phonegap app and that would be loading the images from the local and not from web, so I need to use the Source field instead of URL. However I am not able to test the same using the explorer. What value should I specify in the Source field ?

Related

Create a Sharepoint list in a specific folder with Microsoft graph api

Premise:
I have a folder under the sharepoint site for e.g.
https://... <mycompany-sharepoint-site.com>/
under which we have folder so my url is something like
https://... <mycompany-sharepoint-site.com>/Documents/Sub_folder_1/Sub_folder_2
pertaining to our project.
I need to be able to create a Sharepoint list in the Sub_folder_2 - folder and not at the root level.
With Sharepoint - GraphApi - create list api url
POST https://graph.microsoft.com/v1.0/sites/{site-id}/lists
I will ONLY be able to create at the <mycompany-sharepoint-site.com> level (i.e. at the root level) which is not what I want.
FYI, I already tried (on Postman) to go with the drives//items/<folder_id> - route or I should say attempted to do so but failed.
Any help is greatly appreciated.
If you want to use Graph API to create a folder in SharePoint, please use the following query:
POST /groups/{group-id}/drive/items/{parent-item-id}/children
For more information: https://learn.microsoft.com/en-us/graph/api/driveitem-post-children?view=graph-rest-1.0&tabs=http#http-request
Hope this is helpful.
I don't think that SharePoint supports creating a list inside the folder but you can at least try to create a list and specify the path in the parent reference.
You need to find out the drive id.
POST https://graph.microsoft.com/v1.0/sites/{site_id}/lists
{
"displayName": "Test",
"columns": [
{
"name": "Column1",
"text": {}
},
{
"name": "Column2",
"number": {}
}
],
"list": {
"template": "genericList"
},
"parentReference": {
"driveType": "documentLibrary",
"driveId": "{drive_id}",
"path": "/drives/{drive_id}/root:/Documents/Sub_folder_1/Sub_folder_2"
# or
# "path": "/drives/{drive_id}/root:/Sub_folder_1/Sub_folder_2"
}
}
I don't think it's even possible at all, did you succeed that manually?

Facebook graph api. how to list all pages that my app is subscribed to?

So I am aware of how to check each page to get a list of all subscribed apps.
But I would like to get a list of all pages my app has real time update subscriptions for?
so i have tried this
https://graph.facebook.com/v2.5/$app_id/subscriptions?access_token=$app_token
but this just brings back basic info on the app.
I would like a list of pages that it has subscriptions to already?
Can anyone help?
This doesn't look to be possible.
Endpoint you're using - https://developers.facebook.com/docs/graph-api/reference/v2.8/app/subscriptions - is to get list of application webhooks (callback_url and type of changes), which are called subscriptions for some reason. It's not about pages that subscribed to this webhook (or this app in general).
Overall, even in https://developers.facebook.com/apps/ for your app, under e.g. Messenger tab, you will only see subset of all pages that subscribed to this app. The visible subset is limited by your facebook user account permissions, presumably only show pages that you're either Admin or Editor.
Therefore, if such call would be possible, it would be somehow tied to User Access Token as well, not only app token.
You can do this here: https://developers.facebook.com/tools/explorer
Once logged, you can click on right button and select "Get User Access Token". You will need at least manage_pages or pages_show_list permission to accomplish this.
Now, all you have to do is call this endpoint: /me/accounts.
It should list all subscribed pages on your app.
Hope it helps.
As per
https://developers.facebook.com/docs/facebook-login/access-tokens/#apptokens
it is possible (graph api):
GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
And then /<app_id>/subscriptions
which returns something like:
{
"data": [
{
"object": "application",
"callback_url": "https:...",
"active": true,
"fields": [
{
"name": "ads_rules_engine",
"version": "v2.9"
}
]
},
{
"object": "page",
"callback_url": "https://...",
"active": true,
"fields": [
{
"name": "leadgen",
"version": "v2.5"
}
]
}
]
}

Getting number of page likes, post shares and website clicks

How can I get number of page likes, post shares and website clicks aggregated by ad group. Post comments and post likes are fetched through field 'inline_actions' - https://developers.facebook.com/docs/reference/ads-api/adreportstats#columns (/reportstats/date_preset=yesterday&data_columns=['adgroup_id','inline_actions']&actions_group_by=['action_type']). I need a way to fetch these report items using api, just like they are returned using https://www.facebook.com/ads/manage/reporting.php.
To get data per adgroup level you must include adgroup_id or adgroup_name in data_columns - as you're doing.
Comments, Likes and many other actions are returned in column actions
You can specify which actions types you're interested in by specifying filters:
filters=[
{
"field": "action_type",
"type": "in",
"value": [
"like",
"page_engagement",
"post_engagement",
"post_like",
"comment",
"games.plays",
"post",
"photo_view",
"link_click",
"receive_offer",
"checkin",
"mention",
"tab_view",
"vote",
"follow",
"gift_sale",
"video_play",
"video_view",
"offsite_conversion",
"offsite_conversion.checkout",
"offsite_conversion.registration",
"offsite_conversion.lead",
"offsite_conversion.key_page_view",
"offsite_conversion.add_to_cart",
"offsite_conversion.other",
"app_install",
"app_engagement",
"app_story",
"app_use",
"credit_spent",
"mobile_app_install",
"app_custom_event",
"app_custom_event.fb_mobile_activate_app",
"app_custom_event.fb_mobile_complete_registration",
"app_custom_event.fb_mobile_content_view",
"app_custom_event.fb_mobile_search",
"app_custom_event.fb_mobile_rate",
"app_custom_event.fb_mobile_tutorial_completion",
"app_custom_event.fb_mobile_add_to_cart",
"app_custom_event.fb_mobile_add_to_wishlist",
"app_custom_event.fb_mobile_initiated_checkout",
"app_custom_event.fb_mobile_add_payment_info",
"app_custom_event.fb_mobile_purchase",
"app_custom_event.fb_mobile_level_achieved",
"app_custom_event.fb_mobile_achievement_unlocked",
"app_custom_event.fb_mobile_spent_credits",
"app_custom_event.other",
"rsvp"
]
}
]
However that's optional IIRC, API should send you all non-zero actions by default.

Get total number of Custom Actions on Open Graph Object

I want to access number of custom actions (that I've defined) done on my Open Graph object. Facebook will return number of Like actions in response(like this) but they don't include number of custom actions.
Apps can retrieve actions published for the authorized user. For example, a Recipe app can retrieve all the recipes I've cooked or plan on cooking and customize the app experience based the data.
This API returns the action’s metadata including timestamps along with custom properties and their values. Objects referenced from an action are returned a single level deep.
GET /{action-instance-id}
The following retrieves a specific action instance
https://graph.facebook.com/{action-instance-id}?access_token=USER_ACCESS_TOKEN
Response
{
"id": "1538292028372"
"start_time": 1303502229,
"end_time": 1303513029,
"data": {
"type": "recipebox:recipe",
"url": "http://www.example.com/pumpkinpie.html",
"id": "1234567890",
"title": "Pumpkin Pie"
},
}
The above content is from FB Documentaion

getting high resolution photos that were posted on a page wall/feed

I'm getting my page wall with the open graph.
And when someone posted a photo, I get it on the JSON
{
"id": "27888702146_10150369820322147",
"from": {
"name": "brocoli",
"category": "Record label",
"id": "27888702146"
},
"message": "Vincent Epplay / David Fenech / Jac Berrocal \u00e0 Beaubourg ce soir, 19h, gratos.",
"picture": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc7/305819_10150369820292147_27888702146_8255527_583491475_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=10150369820292147&set=a.386279807146.165840.27888702146&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"type": "photo",
"object_id": "10150369820292147",
"created_time": "2011-10-16T08:22:21+0000",
"updated_time": "2011-10-16T08:22:21+0000",
"likes": {
"data": [
{
"name": "brocoli",
"category": "Record label",
"id": "27888702146"
},
{
"name": "Agathe Morier",
"id": "601668526"
}
],
"count": 2
},
"comments": {
"count": 0
},
"is_published": true
}
The problem is that the picture link is a low resolution copy of the picture.
How can I get the URL of the full picture ?
Thanks!!
Best
Geoffroy
You can get different version of the photo by querying Graph API with its object_id (not photo post_id which is id in results you provided).
Once you'll request the photo by object id you'll get array of images with URLs and dimensions:
http://graph.facebook.com/10150369820292147?fields=images
If you're attempting to access posts on a Facebook Page (such as for a company) instead of typical user profile, you firstly need to fetch the feed like this:
https://graph.facebook.com/v15.0/YOUR_PAGE_ID_HERE/feed?fields=attachments&access_token=...
And then access data[0].attachments.data[0].subattachments.data[0].target.id to get the object ID (or "target ID" in this case) which you can then use to perform an additional query to obtain the higher resolution image. Increment the numbers to get additional posts and images inside each post.
All you need to do is :
http://graph.facebook.com/me?fields=picture.height(961)
// replace 961 with your required height which u want
You can do this from the main posts list now using
/v2.3/105753476132681/posts?limit=5&fields=likes.summary(true),comments.summary(true), attachments
If attachments doesn't work, try full_picture - but that just gave the 100x100 image for me as well.
Attachments returns a data hash with a 640x480 version of the image at least (not sure what my orig. photo size was)
Use this Code. Its Work for me and get Clear Image
String PICTURE_URL;
String getPicture = hashMap.get("picture");
if (getPicture.contains("_t.")) {
PICTURE_URL = getPicture.replaceAll("_t.", "_n.");
} else if (getPicture.contains("_a.")) {
PICTURE_URL = getPicture.replaceAll("_a.", "_n.");
} else if (getPicture.contains("_s.")) {
PICTURE_URL = getPicture.replaceAll("_s.", "_n.");
} else if (getPicture.contains("_q.")) {
PICTURE_URL = getPicture.replaceAll("_q.", "_n.");
}
url=new URL(PICTURE_URL);
Bitmap bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
((ImageView)view.findViewById(R.id.imageView_FullImage)).setImageBitmap(bitmap);
Though requesting a photo by its object_id will return an array of images with different dimensions, in some cases this approach would require an additional call to the Facebook API.
A simpler approach is to add full_picture to your list of parameters, which will extract the highest resolution image associated with the post.
/v2.2/6275848869/posts?fields=full_picture
For example, if you want to extract all the posts from a Facebook page in the past X days, with the object_id approach you'd need to call the API 3 times:
To get the page info.
To extract the list of posts and obtain the object_id for each post.
For each object_id, to retrieve the list of higher resolution images.