I'm trying to figure out if the following is possible with the Graph API:
Post a message on the wall of a user (who has permissions publish_stream and offline_access set) on behalf of that user, so the poster doesn't depend on the current session.
This seemed to be possible with the old rest api (stream.publish). This function has some known bugs though and seems te be deprecated.
With the new api it's possible to publish on a users wall but it doesn't take the poster as an argument (as did stream.publish). See here.
Is this because Facebook doesn't allow such third party publishing anymore, or am I missing something here?
Any help would be greatly appreciated,
from here http://developers.facebook.com/docs/reference/javascript/FB.api
If you have an authenticated user with
the publish_stream permission, and
want to publish a new story to their
feed:
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
it is the javascript version but i am pretty sure there is an equivalent one for php
Related
I am trying to post photo/video on facebook wall using me/photos and me/videos/ method, which requires publish_actions ,user_photos and user_videos extended permissions. I submitted my app for Facebook review for approving extended permissions. I got reply saying that "People must enter all content in the user message field. Your app can't auto-populate the message field with any content, including links and hashtags, even if you allow users to edit the content before sharing."
As per the review feedback I have to allow user to edit the p refilled messages, The method I am using not showing share pop up to edit. Please guide me how to open facebook share pop up to edit the content.. Thanks in advance !!
FB.api('/me/photos?access_token='+accessToken, 'post', { url: fileUrl, 'message':description,access_token: accessToken }, function(response) {
if (!response || response.error) {
console.log("error occured");
// alert('Error occured: ' + JSON.stringify(response.error));
} else {
alert("Successfully posted on facebook");
// $("#status").html("Successfully posted on facebook");
}
});
The following code to write to a friend's wall from an app is returning an error. How can I debug this? The user ID (VALID_USER_ID) used below is valid - I read it from a separate function. The same problem happens when I do FB.api('/me/feed', 'post'...). What am I doing wrong?
function postToFeed()
{
FB.api('/VALID_USER_ID/feed', 'post',
{
message: 'Testing the Facebook JavaScript API',
link: 'http://developers.facebook.com'
},
function(response)
{
if (!response || response.error)
{
console.log('Error occured');
}
else
{
console.log('Post ID: ' + response.id);
console.dir(response);
}
});
You cannot post to a friend's wall, if you logged the error response you would see that.
Facebook has disabled posting to a friend's wall
Post to friends wall via the API generate a high levels of negative user feedback, including “Hides” and “Mark as Spam" and so we are removing it from the API. If you want to allow people to post to their friend’s timeline from your app, you can invoke the feed dialog. Stories that include friends via user mentions tagging or action tagging will show up on the friend’s timeline (assuming the friend approves the tag).
https://developers.facebook.com/blog/post/2012/10/10/growing-quality-apps-with-open-graph/
I am wondering if it is possible to post through a Facebook app to an associated page as if the post was done on the page itself. I.e. if I am logged onto Facebook and I go to a page I am admin for, then when I post it will appear with the name of the page rather than my Facebook name. I would like to replicate this behaviour but coming from an external website connecting through a Facebook app. I have made all of the connections and I am able to post ok but it is coming through as my name. I am using the Javascript API with the following to login:
FB.login(function(response) {//do some login processing},
{scope: 'publish_stream'});
Then I publish the message with the following after logging in and accepting the permissions:
FB.api('/[PAGE NAME]/feed', 'post', { message: Text to post }, function(response) {
if (!response || response.error) {
alert('Error occurred '+response.error.message);
} else {
alert('Post ID: ' + response.id);
}
});
My Facebook App has the Site URL and App Domain set correctly and I have setup the App as a Page Tab and combined that to my page.
So if anyone can let me know if it is possible and how to do it, it would be greatly appreciated
Thanks
It's all about Authentication, you have a User Access Token but you need a Page Access Token to authenticate as a page.
Here is the doc: https://developers.facebook.com/docs/authentication/pages/
I just created an app on Facebook (Open Graph). I want to publish a feed on the user's wall if they read that page. I can get it to execute in Unix Terminal but its not working via PHP or HTML. It should function like the Washington Post Social Reader where whenever you read a story, it shows up on your wall..saying "XYZ read a story on WashingtonPost"..I've got all setup done except for the last part.
I need to use a function in my website that will fire when the page loads..sending a post request to Facebook and publish the feed to the reading user (Provided they have authenticated my app).
I tried using the following method provided by Facebook but it didn't work
<script type="text/javascript">
function postCook()
{
FB.api('/me/YOUR_NAMESPACE:cook' +
'?recipe=http://example.com/cookie.html','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
Please help ASAP
Log the error and see what Facebook tells you:
console.log('Error occured => ' + response.error.message);
Also use the Facebook debug tool to check your meta tags.
I suppose the answer is pretty simple, but i cant find conclusive answer either way.
Is it possible to use facebook to log in a user, fetch their friends, allow them to select them and then post to their profiles in turn, even if that means firing up a custom modal with html to select from the list of users friends before passing the IDs on to the publishStream function in a loop.
Any response would be dandy. Thanks guys and gals.
If you post to the logged-in user's stream, you have no control over which friends see it in their own streams.
Alternatively, you can send facebook notifications to friends that were selected, subject to the daily notification limit imposed on your app by facebook. Be aware that facebook is phasing out noficiations.
You can do exactly what you said. Just get the list of user IDs before hand using your custom dialog you mentioned. Then call the FB.ui function repeatedly, populating the "to" parameter with each friend ID.
FB.ui(
{
method: 'feed',
to: #,
name: 'name of post',
link: 'http://link.com',
picture: 'http://link.com/image.jpg',
description: 'descriptive text',
},
function(response) {
if (response && response.post_id) {
alert('Post was published.'+response);
} else {
alert('Post was not published.'+response);
}
}
);