Can't hide/unhide Facebook comment through Post API - facebook

When I try to Hide Comment through Post API, I had received following error. Any solutions to resolve this error?
result = fb.Post(url, new
{
access_token = fanpage.AccessToken,
is_hidden = false
});
Facebook.FacebookOAuthException: (OAuthException - #200) (#200) Can not hide or unhide this comment

Related

How to fetch page list from Facebook Graph API?

I can download user events but not user managed pages. Why? What is the difference?
Using react-facebook-login to get user access token
import FacebookLogin from "react-facebook-login";
Adding Facebook login to the screen, it has the pages_show_list permission:
<FacebookLogin
appId={fbAppId}
autoLoad={true}
fields="name,email,picture"
scope="public_profile,pages_show_list"
onClick={this.componentClicked}
callback={this.responseFacebook}
And here is the handler:
responseFacebook = response => {
this.setState({
accessToken: response.accessToken,
isLoggedIn: true,
userID: response.userID,
name: response.name,
email: response.email,
picture: response.picture.data.url
});
axios.get('https://graph.facebook.com/v5.0/me/accounts&access_token='+response.accessToken)
.then(response => {
console.log("aaa " + response);
console.log("bbb ");
})
};
Second breakpoint will not be reached.
But get a lot of strange error:
Facebook API Explorer returns the data
Code is here: https://gitlab.com/j4nos/ticket-portal/blob/master/src/App.js
But get a lot oof strange error:
Focus.
The main part of importance here is that it shows that you are getting a 400 Bad Request response from the API, with that URL you tried to request there.
https://graph.facebook.com/v5.0/me/accounts&access_token=...
How does the query string portion of a URL start again ...?
Question mark, not ampersand.

How to post on wall when app is in development mode?

I have a new web app in development mode, and am trying to post to a users wall using something like this:
<fb:login-button scope="publish_pages" autologoutlink="true" onlogin="OnRequestPermission();">
</fb:login-button>
...
var params = {};
params['message'] = 'Message';
params['name'] = 'Name';
params['description'] = 'Description';
params['link'] = 'http://www.example.com';
params['picture'] = 'http://example.com/example.png';
params['caption'] = 'Caption';
FB.api('/me/feed', 'post', params, function(response) {
if (!response || response.error) {
console.log(response.error);
} else {
alert('Published to stream - you might want to delete it now!');
}
});
I am testing this after a successful login using the FB account defined in that app as admin, but am getting an OAuthException error:
"(#200) The user hasn't authorized the application to perform the action"
Do I need to send the app through review to get additional access even though we are in testing? Is there something else I missed here?
Thanks
You are using the wrong permission, you would need publish_actions to post to the user wall. publish_pages is for posting to a Page you own. You do not need to go through the review process for testing, all permissions work without review for users with a role in the App.

Facebook Graph API - How to search friends by relationship_status?

I'm using the Facebook AS3 API and I'm having trouble sorting friends by relationship_status. I'm using the following call:
Facebook.API("/" + UID + "/friends?relationship_status='single'&access_token=" + ACCESS_TOKEN);
I have the following permissions enabled:
"publish_stream","read_friendlists", "user_photo_video_tags", "user_relationships", "user_checkins", "user_interests", "user_photos", "friends_relationships", "friends_relationship_details"
Is there something I'm missing permissions-wise?
I've tried this on the Graph API Explorer and it just doesn't work. From my Flash application I get the following error:
OAuthException : Error validating application.
I'm not having any other authentication problems with other calls thus far.
I appreciate any help or insight you can provide. Thanks!
So I ended up doing this via a batch request. Code below:
var batchObj:Array = [
{
method:"GET",
name: "get-friends",
relative_url: "me/friends"
},
{
method:"GET",
relative_url: "?ids={result=get-friends:$.data.*.id}"
}
];
var batchRequest:String = JSON.stringify(batchObj);
var params:Object = {
access_token: _accessToken,
batch: batchRequest
}
Facebook.api("/", onRequestComplete, params, "POST");

Inviting selected users to Facebook-Event (via Graph API)

with help of docs, tutorials and this forum I managed to create an event for the logged in user on his profile or page, as he chooses.
I also figured, that for inviting friends I'd have to use events.invite.
Since I don't want to invite all of the user's friends but several, I implemented a request, which as a result returns the selected friend's ids.
Those I'm using for the events.invite call. I get bool 1 as result (which means, the invitation was sent successfully) but there is no invitation to be seen in friends bookmarks or event page.
Everything besides invitation is working.
3 questions come up:
1) Does events.invite need additional permission besides 'create_event' ?
I tryed events.invite independently and couldn't get results either...
2) Is there a better way to select friends before sending invitation? I do not want app request being sent out each time an event is created.
3) If 2 is negative, how can the app request (and bookmark) be subdued or removed from friend's profile? Deleting the request via API obviously doesn't remove the message in application requests.
* in main script: [javascript]
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'Test',
title: 'event invitation for up to 20 friends',
max_recipients: 20,
},
function (response) {
if (response && response.request_ids) {
var requests = response.request_ids.join(',');
var invite_ids = new Ajax.Request('/facebook/handle_invitation.php', {
onSuccess: function(test) { alert('Done!'); },
method: 'post',
parameters: {tid: '<?php echo $target_id; ?>',
request_ids: requests,
eid:'<?php echo $event_id; ?>',
token: '<?php echo $access_token; ?>'}
});
} else {
alert('canceled');
}
});
return false;
}
* and in 'handle_invitation.php' (called from request response):
if( isset($_POST['request_ids']) && isset($_POST['uid']) ) {
$target_id = $_POST['tid'];
$event_id = $_POST['eid'];
$access_token = $_POST['token'];
$requests = explode(',',$_POST['request_ids']);
foreach($requests as $request_id) {
$request_data = $fb->api("/$request_id?$access_token");
$invite_id[] = $request_data['to']['id'];
$fb->api("/$request_id?$access_token", "DELETE");
}
//invite friends to my event
$return = $fb->api(array(
'method' => 'events.invite',
'eid' => $event_id,
'uids' => $invite_id,
'personal_message' =>"Einladung zu meinem Event"
));
}
Hope this was not too detailed. I'd appreciate any help, since after days of reading and experimenting I'm finally stuck at this point. Thx!
The graph api now allows you to invite users by user_id. See http://developers.facebook.com/docs/reference/api/event/
invited
Create
You can invite users to an event by issuing an HTTP POST to /EVENT_ID/invited/USER_ID. You can invite multiple users by issuing an HTTP POST to /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3. Both of these require the create_event permission and return true if the invite is successful.
I don't think "sent event invitation" is in the GRAPH API yet. It is available in REST API but its not working as we expect.
I found some known issues and limitations with facebook events. Please see the links below from the official documentation on facebook
Limitation on number of people that could be invited to an event.
http://www.facebook.com/help/?faq=12576#!/help/?faq=202545109787461
Event members are not receiving messages I have sent.
http://www.facebook.com/help/?page=786#!/help/?faq=188295427885002

Facebook Exception #100 : Does not resolve to a valid user ID

While trying to post to a user's facebook wall using PHP, I am getting the error
{
"error": {
"type": "OAuthException",
"message":"(#100) http:\/\/spats.in\/nssc2 does not resolve to a valid user ID"
}
}
This is my code :
$apprequest_url = "https://graph.facebook.com/feed";
$mymessage="Hello World!";
$parameters = "?" . $access_token . "&message=" . urlencode($mymessage) . &id=".urlencode('http://spats.in/nssc2')."&method=post";
$myurl = $apprequest_url . $parameters;
$result = file_get_contents($myurl);
What is the problem?
One reason for getting the (#100) <url> does not resolve to a valid user ID error is that the page has its Open Graph meta tags set incorrectly. You can use Facebook's Open Graph Debugger to see what might be wrong.
I figured it out myself. The request URL should have been http://graph.facebook.com/me/feeds/ and no id parameter was required.