How to comment in a closed group facebook api graph - javascript

I am developing on API Graph Facebook. I'm using JavaScript SDK. I want to comment in a group where I have published.
The problem is some groups are closed, although I am in these groups.
How can I comment in this groups?
For example, if I am in the explorer of Facebook developers I try to get a post mine, but when I execute the GET I obtain this error.
{
"error": {
"message": "Unsupported get request. Object with ID '114576608727103_527470874104339' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "DVXM6hFnfeF"
}
}
I have same problem when I try to use POST method. I can comment in a groups open normal.
Note: I am in all groups that I want to comment.
Thank you.

Related

Facebook API - POST a comment on a private groups post

I have successfully retrieved an post made on an private group and the comments made on this post. I want also to make the users on my app to be able to reply to comments on that post but cant get my head around this problem.
This is the API URL to GET all the comments on an post ID.
1338804626636796_1351943298656262/comments
When i try to do a POST call to this URL i get as a result:
{ "error": {
"message": "(#3) Publishing comments through the API is only available for page access tokens",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "AM6a-he8gLoFA8SDVHjfDYO"
}
}
As far as i understand Page Access Token is used to manage Pages... Im working with Groups not Pages, and when i try to create a Page Access Token my Group that i want to manage wont show up ofcourse.
I then follow this guide:
Get a page Access Token API Docs
It asks for a PAGE ID, i have group ID but i try it anyways and get this as a response:
code: 100 fbtrace_id: "AnzTkEAsbp8s-Z__QawDBYX" message: "(#100) Tried accessing nonexisting field (access_token) on node type (Group)" type: "OAuthException"

Can't correctly obtain OAuth to append to google sheet via Javascript http request

I can't for the life of me append to my google sheet via http request. More specifically I can't seem to get the Oauth formatting right. I don't want/need a uri or prompt for permission as its just me managing my own spreadsheet. First, I was trying with just my api key, but then found out that if you're editing data you need to obtain an access token. That's when I started trying to obtain the token through oauth2 following the TERRIBLE google api documentation. That's where I hit a wall and have just about given up. It's such a simple concept, I just want to add data to my spreadsheet on drive from an online script (housed on scriptr.io), but Google yet again makes things so unneccessarily complicated and don't help matters with their convoluted, misleading, and scattered documentation. Can someone please help me in accomplishing this? Here's where I'm at or what progress I've made thus far.
I've figured out how to correctly format the call to add a row of data to the spreadsheet.
POST https://sheets.googleapis.com/v4/spreadsheets/-/values/Raw%20Data!A1:D1:append?valueInputOption=USER_ENTERED
//Header
Authorization: Bearer {oauth_token}
//Payload
{"range": "Raw Data!A1:D1","majorDimension": "ROWS","values": [["Test", "$15", "2", "3/15/2016"]]}
I know the above works because I've successfully added the data using the OAuth 2.0 Playground. However, when trying it outside of the playground (on a rest client) I keep getting errors trying to obtain the token.
POST https://www.googleapis.com/oauth2/v4/token
scope=https://www.googleapis.com/auth/spreadsheets
client_id=------&
client_secret=-----&
refresh_token=-----&
grant_type=refresh_token&
access_type=offline
I use the client id & client secret from my api console and I use the refresh token I got by authorizing the spreadsheet api in the oauth playground, but the above POST request leads to the following error
Error 400
{
"error": "unsupported_grant_type",
"error_description": "Invalid grant_type: "
}
Can someone please help me figure out how to correctly do this?

Get newest post from a Facebook page as a string in JavaScript

I simply need to get the newest post from a specific Facebook page as a string in JavaScript for a website. I have never used the Facebook API and I'm still new to JavaScript, after many attempts I just can't figure out what the problem is...
So far this is everything I've done:
Created a Facebook app, chose 'website' for the platform
Inserted the JavaScript SDK code that I got from Facebook into my website code and replaced the placeholder 'appID' with the 'App ID' from my Facebook app
Became admin to the Facebook Page
On the Graph API Explorer page used the 'Get Token' dropdown to select 'Get Page Access Token', then selected the Facebook Page that shows up in the dropdown
Used the following request in the Graph API Explorer: 'https://www.facebook.com/pagenamehere/?fields=posts.limit(1)' (The output provides the post I need but with some extra information like "create_time", "id", etc. that I will most likely remove in JavaScript unless there is a more precise request I can use instead since I only need "message")
Copied the provided JavaScript code from 'Get Code' and inserted this under the JavaScript SDK code
replaced '//Insert your code here' with 'alert (response)', the alert message is: [object Object]
Either I don't know how to obtain "message" from '[object Object]', or I'm not getting the response I need. I've tried to do this with the webpage on a live server.
Please help, I'm out of ideas and I've read the Facebook API too many times.
Thanks in advance.
It's simple. Just have a look at the Graph API Explorer, and you'll get the idea how to access the message property:
Sample Graph API Explorer call
A call to /buzzfeed/feed?limit=1 will return
{
"data": [
{
"message": "science",
"created_time": "2015-11-23T07:01:00+0000",
"id": "21898300328_10154109572045329"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.5/21898300328/feed?limit=1&format=json&since=1448262060&access_token=&__paging_token=&__previous=1",
"next": "https://graph.facebook.com/v2.5/21898300328/feed?limit=1&format=json&access_token=&until=1448262060&__paging_token="
}
}
which means that
console.log(JSON.stringify(response.data.message));
should print you the message.
Thank you for your suggestions, they helped point me in the right direction and I was able to get this to work.
Here are the missing steps from my original post required to make it work:
Had to also add my domain to the 'Valid OAuth redirect URIs' field in 'My Apps' -> 'Settings' -> 'Advanced'
My access token had to be included in the code generated from the Graph API Explorer, like the answer in this post:
(your user access token should be extended to 60 days in the 'Access Token Tool' page by clicking 'debug' -> 'Extend Access Token' and using this token in the code)
The Facebook SDK needs to finish loading before the code generated from the Graph API Explorer is executed, I used Mohammed Arif's answer from this question to do this but I had to use a delay for it to work. I put his code in a function that runs after a 200ms setTimeout, if it is loaded the code generated from the Graph API Explorer executes, else I run the function after a 200ms setTimeout again.
Tobi's answer to part of the question (to get the message) was almost correct: response.data[0].message;

How do you integrate the Parse Javascript API with Appcelerator and not use undocumented calls?

I would like to create a user from his/her Facebook credentials without using undocumented calls. I do not believe it is possible based on the current implementation of Parse Javascript Library for two known reasons:
1. The current implementation of the library does not support the Appcelerator HTTP client so it fails immediately. I have addressed this issue by extending the existing Parse Javascript library's ajax method to utilize the Appcelerator HTTP client.
http://www.clearlyinnovative.com/blog/post/34758524107/parse-appcelerator-titanium-the-easy-way
There has been approximately 2K views on the slide deck I created and about the same on the blog post, so it is pretty clear to me people want this to work.
2. The current implementation of the library assumes you are integrating with the Facebook Javascript library and that library does not work with Appcelerator either. In fact Appcelerator has integrated Facebook directly into the framework so there is no need for the javascript library. All of the information required to link a user account to Facebook can be easily gotten using the API calls that Appcelerator developers are already familiar with.
The original question was removed from the Parse Support forum so I am looking for a solution from a wider community.
Hi Aaron,
It's not helpful to other developers to promote using undocumented
APIs in the Parse library as a workaround, so I make the decision to
unlist it. I understand it might help in your particular case with
Titanium, and you're well aware of the implications of using private
APIs, but other users might overlook that warning. I hope you
understand.
Héctor Ramos Solutions Architect, Parse https://parse.com/help
This is the code that was too dangerous to be left visible on the forum:
// setting auth data retrieved from Ti.Facebook login
authData = {
"facebook" : {
"id" : Ti.Facebook.uid,
"access_token" : Ti.Facebook.accessToken,
"expiration_date" : expDate, // "format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
}
};
// Either way I resolved the problem, calling _handleSaveResult(true) on the returned user object,
// I just dont think it should have been as difficult as it was
// attempt to log the user in using the FB information
var user = new Parse.User();
user.save({
"authData" : authData
}).then(function(_user) {
// force the user to become current
_user._handleSaveResult(true); //<-- this is the evil method I called
if (!_user.existed()) {
// add additional user information
var userInfo = {
"acct_email" : "bryce#xxxxxx.com",
"acct_fname" : "Bryce",
"acct_lname" : "Saunders"
};
return _user.save(userInfo);
}
}).then(function(_user) {
alert('Hooray! Let them use the app now.');
}, function(error) {
alert(' ERROR: ' + JSON.stringify(error, null, 2));
});
Question on Appcelerator Forum
http://developer.appcelerator.com/question/152146/facebook-appcelerator-and-parse-integration-need-help
Question on Parse Forum
https://parse.com/questions/how-do-you-integrate-the-parse-javascript-api-with-appcelerator-and-not-use-undocumented-calls
Maybe this part of a newer SDK, but can't you just call:
Parse.FacebookUtils.logIn({
"facebook": {
"id": "user's Facebook id number as a string",
"access_token": "an authorized Facebook access token for the user",
"expiration_date": "token expiration date of the format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
},
{
success : function(_user) {},
error : function(_user, error) {}
}
};
It's not documented in the Javascript guide, but it is documented in the unminified version of the code visa vie:
#param {String, Object} permissions The permissions required for Facebook
log in. This is a comma-separated string of permissions.
Alternatively, supply a Facebook authData object as described in our
REST API docs if you want to handle getting facebook auth tokens
yourself.
I made some updates to your original code to support the lastest SDK which I'm going to publish on Github.
Thanks so much for spearheading this effort. Your original post saved me hours.

Publishing Open Graph Action to Groups

I would like to be able to publish OG Actions to Facebook groups. I am able to publish the action as follows:
POST https://graph.facebook.com/me/appfoundry:annotate
{article: http://synchro.herokuapp.com/articles/10}
This works great, and the annotation shows up in my news feed. But when I try to publish to one of my groups,
https://graph.facebook.com/305900672779368/appfoundry:annotate
{article: http://synchro.herokuapp.com/articles/10}
I get the following error:
{
"error": {
"message": "(#240) Requires a valid user is specified (either via the session or via the API parameter for specifying the user.",
"type": "OAuthException",
"code": 240
}
}
I would like these actions to be visible only in the groups, which might be private or secret, and I do NOT want them to show up in a user's news feed or ticker.
I am using the Graph API Explorer with my app selected, which has user_groups, publish_stream, publish_actions, share_item and status_update permissions.
What am I missing?
Thanks,
Marty
This is not possible, only Users can publish Open Graph actions.
A user can choose who can see their actions, but can't currently only allow just members of a group to see those actions.

Categories

Resources