I had the ability to post from my website to my page some time ago, it seems there have been some changes made to the API since then now when I use the below snippets I get the error message
{"message":"(#100) Only owners of the URL have the ability to specify the picture, name, thumbnail or description params.","type":"OAuthException","code":100,"fbtrace_id":"AsGjV6ebkihnC60tRtHM4f3"}
Code
function postToFeed(id, desc, name) {
var page_id = ************;
var app_id = ************;
FB.api('/' + page_id, {
fields : 'access_token'
}, function(resp) {
console.log(resp);
if (resp.access_token) {
FB.api('/' + page_id + '/feed', 'post', {
message : desc,
link : 'https://link',
name : name,
from : page_id,
description :'',
access_token : resp.access_token
}, function(response) {
if (!response || response.error) {
alert(JSON.stringify(response.error));
} else {
alert('Post ID: ' + response.id);
}
});
}
});
Yes, like the error message suggests, this changed some time ago. See the respective section
Custom Link Page Post Image
in the docs for more information: https://developers.facebook.com/docs/graph-api/reference/v3.3/page/feed
You can of course also just remove the custom description parameter.
Related
I'm using Facebook's JavaScript SDK to create a custom story.
FB.login(function() {
FB.api(
'me/' + fb_app_namespace + ':review_a_book',
'post',
{
book: "http://samples.ogp.me/199815506812566"
},
function(response) {
// handle the response
if (!response) {
alert('Error occurred.');
} else if (response.error) {
$('#result').text('Error: ' + response.error.message);
} else {
$('#result').html('<a href=\"https://www.facebook.com/me/activity/' +
response.id + '\">' +
'Story created. ID is ' +
response.id + '</a>');
}
}
);
}, {scope: 'publish_actions'});
The Custom Story 'Review A Book' is setup in the App Dashboard and the JS fires correctly without error. The problem comes in when I try to view the Activity in my Activity Log. It just isn't there. Also the link generated presents me with a page that simple says 'This content is currently unavailable'.
The Application is Public, and at the very least should work with me as an Admin or Developer.
Any help would be appreciated.
we are using Fb API for post feed on facebook.
my code is -
if (response.authResponse) {
var data =
{
name: "link to apply",
picture: 'http://www.hrgp.biz/Uploads/CompanyForTesting_499/NotesReminders/2608chemtec-logo.jpg',
link: "http://www.hrgp.biz/bc0efdb3-f1a7-4d81-9635-d1418e808b6d.aspx", // Go here if user click the picture
description: "thank you"
}
FB.api('me/feed', 'post', data, function (response) {
if (!response || response.error) {
alert(JSON.stringify(response.error));
} else {
//alert('Post ID: ' + response.id);
alert('feed posted successfully.');
}
});
}
}, { scope: 'email,user_likes,publish_actions,publish_stream,read_stream,photo_upload' });
This code Works but I’m having issues with the picture. It doesn’t show up in the post.
how can i resolve this issue?
or
please tell me if any problem into my code.
thank you..!!!
Please refer to What is the minimum width and height Of Facebook Open Graph Images?.
The ratio of both height divided by width and width divided by height
(w/h, h/w) cannot exceed 3.0.
Your photo, http://www.hrgp.biz/Uploads/CompanyForTesting_499/NotesReminders/2608chemtec-logo.jpg, 250/65 = 3.84615384615 obviously exceed the maximum ratio:
FB.api('me/feed', 'post', { message: body,
picture :'PICTURE_URL',
description : "DESCRIPTION"
}
, function (res) {
if(!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log('Post Id: ' + res.id);
for more options check - https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed
I have tried to post a message on my wall using FB.api(). I posted it successfully but it's showing only for me. I want to make this post public.
In app Configuring permissions i set "Default Activity Privacy" value Public but still message posting private.
I tried to do it by following code:
FB.login(function (response) {
if (response.authResponse) {
var privacy = { 'value': 'EVERYONE' };
var txt = 'my post to test feed post using api';
FB.api('me/feed', 'post', { message: txt, privacy: privacy }, function (response) {
if (!response || response.error) {
alert(JSON.stringify(response.error));
} else {
alert('Post ID: ' + response.id);
}
});
}
}, { scope: 'email,user_likes,publish_actions,publish_stream,read_stream' });
Please check my code.
As said in reference 'privacy' field value should be string.
Try to pass "{ 'value': 'EVERYONE' }" as string, not an object.
I need to post on the wall of a user as if it were itself (offline token), but when logged in with another user. Example:
I login with user X. In some moment I want to post on the wall of the user Y as if he had posted (using offline token).
Ps:
I do not want this:
var wallPost = {
message : " My message",
};
FB.api('/USER_ID/feed', 'post', wallPost , function(response) {
if (!response || response.error) {
console.log("facebook error: " + response.error);
}
});
I need the post is in "FB.api ('/ME/feed', 'post', wallPost, function (response) {"
But this "ME" is not the logged user, but the user owns of the offline token.
You cannot do that with the Javascript API because the FB.api call will only use the access token for the currently logged in user. You will need to build a call directly to HTTP post the message to the https://graph.facebook.com/me/feed?access_token={the offline access token you have}
SOLUTION:
Just insert the acess_token in JSON parameter.
var wallPost = {
message : " My message",
access_token : "ACCESS_TOKEN_OFF_LINE_OF_THE_USER"
};
FB.api('/me/feed', 'post', wallPost , function(response) {
if (!response || response.error) {
console.log("facebook error: " + response.error);
}
});
I'm working on a Facebook app that uses Facebook groups, and I'd like to open up a Feed dialog to let the user post a notice to the group's feed. I have a user who is in the group and I've got the relevant permissions as well.
I've tried passing the group's Facebook id in the https://developers.facebook.com/docs/reference/dialogs/feed/ feed dialog, but get a Facebook error. There doesn't appear to be a programmatic way to do it either: the group's feed (described at https://developers.facebook.com/docs/reference/api/group/) isn't documented to accept POSTs either. Is there a way to post a message to the group using the Graph API or one of the other API methods?
I just made a test and it's working as any other wall.
I made a POST to 'GROUP_ID/feed' with a message variable with a value and it worked. I logged into the app as the group owner.
Using facebook php-sdk:
$facebook->api('GROUP_ID/feed', 'POST', array(
'message' => 'Testing...'
)));
I would suggest to use javascript instead as it wont cause post back of our website.
Check out my application to see if that what you want -> WooTube
function Promote() {
var lnk =
'http://www.wootube.woolei.com?v=<?php echo $_GET["id"] ?>';
FB.login(function(response) {
if (response.authResponse) {
//Post To WooTube Group
FB.api('/271691796276524/feed', 'post', {
message: lnk,
link: lnk,
},
function(response) {
if (!response || response.error) {
//alert('You have to join the group first!');
} else {
//alert("Successfully Posted to WooTube Group!");
}
});
//Post to Wootube Page
FB.api('/173724382762792/feed', 'post', {
message: lnk,
link: lnk
},
function(response) {
if (!response || response.error) {
//alert('You have to like http://www.facebook.com/WooTubes first!');
} else {
//alert("Successfully Posted to WooTube Page!");
}
});
} else {
alert('Not logged in');
}
}, {
scope: 'publish_stream'
});
}