Facebook Opengraph action publishing error - facebook

I'm trying to create a read button for my application. I have implemented the code as per the tutorial, but when i click publish button it says Error Occurred
<script type="text/javascript">
function postArticle()
{
FB.api(
'/me/svolzesocial:news.reads?article=<?php the_permalink() ?>',
'post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Successful! Action ID: ' + response.id);
}
});
}
</script>
I also tried debugging, but its showing no error there.
I have created publish button on this page Svolze post Please help me out to sort this problem!

You're posting to the wrong URL.
If you're using the build in read action you should post to
/me/news.reads
If you're using a custom action you should post to
/me/yournamespace:youractionname
At the moment, you're convoluting the two.

Nikhil,
Please also console.log(response) when there is an error to help debug. My guess is that you don't have the correct permissions - you will need publish_actions to publish on the user's behalf. Add a login button with the correct scope and then try to publish.
Some resources:
Perms page
Graph API Explorer

Related

FB.api 'post' returns error

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/

Facebook-login issue

This is our link for the fb or old way sign-in: http://www.greeceinsiders.com/login
Does the fb-login work to you? When I click it it redirects me to the same page.
Sometimes it works sometimes not. When a user logs in with fb we collect his vredentials sucha as email,city, name in our mysql database. Does anybody had the same problem? Is there any good tutorial out there, that explains it step by step and is for the current fb api?
Any suggestions or feedback is welcome, thank you! Some code
FOUND IT!
I like to use the FB.login method. This allows me to set the permissions that I want (such as email) and access the info on my server through a Facebook library like https://github.com/facebook/php-sdk. There are also good tutorials on https://developers.facebook.com/docs/authentication/:
FB.login(
function(response) {
if (response.authResponse) {
$.ajax({
url: Global.base_url + 'user/facebook_log_in/',
dataType: 'json',
success: function(data) {}
});
}
else {
// Display facebook error
}
},
{
scope: 'email'
});

Posting remotely to a Facebook page but post owner showing as from page

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/

Post Automatically Using Open Graph

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.

Facebook OpenGraph - issues with Activity Plugin

I've been able to post activities to my personal wall and timeline, but I don't seem to be able to get the Activity Plugin to go no matter how I call it. I get a success when I call it, and have also been getting a success code from the command line CURL calls.
<script type="text/javascript">
function postAttend()
{
FB.api('/me/kaplangraph:attend' +
'?class=http://samples.ogp.me/253928254644843','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
This I know is working. I see them on my personal timeline. I can't however pull them up in the Activity Plugin. All of the following show up blank. Am I missing something?
<fb:activity action="kaplangraph:attend"></fb:activity>
<fb:activity actions="kaplangraph:attend"></fb:activity>
<fb:activity actions="kaplangraph:attend" app_id=253477038023298></fb:activity>
<fb:activity app_id=253477038023298></fb:activity>
<fb:activity site_url="https://severe-winter-5145.herokuapp.com/"></fb:activity>
Thanks guys, I also posted to the FB developer group ... hoping to get an answer there.
I will post if I find anything, but I agree this is a bug and not a beta issue. It says in the example that this will work for devs/admins/etc ... just not the world. I am guessing somehow in the transition they killed the activity feed, as I am having trouble with others as well.
The Facebook timeline and new open graph are still in beta. I'm pretty sure it won't show up in the activity plugin until it is out of beta.
I think this is a bug; Yes, they are in beta, but the tutorial makes no mention of the fb:activity not working. It is also unclear what parameters should be passed (action or actions). I too have tried various ways of trying to get fb:activity to work, but for now I am waiting to see if there is any update to address this issue.