**I am Looking for solution of my problem. after applying following code i am having error for permission
image
FB.api("/me/events", 'post', eventData, function (response) {
if (response.id) {
alert("We have successfully created a Facebook event with ID: " + response.id);
}
return false;
})
Creating Events is not possible with the API. At least not anymore, it was possible many years ago.
Reference: https://developers.facebook.com/docs/graph-api/reference/user/events/#Creating
Related
My app is able to create a read action successfully using the following code:
FB.api('/me/xyz:listen_to&song=<?=curPageURL()?>','post');
I need to give a link to delete the same story. My issue is, how do i get the id of the latest story i added s i can delete it. Can I get this id via php?
I got the following code from google search, but cannot figure out how to get the id that is passed in to the function.
function deleteAction()
{
FB.api(
'<?=$actionID ?>',
'delete',
function(response) {
alert('action deleted')
});
}
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'
});
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
I've put together a script, with the help of another SA post, but the issue I'm having is it's always returning error. When logging the error with console log it contains no properties so I can't determine why I am getting the error.
$(".add-image").click(function() {
FB.login(function(response) {
if (response.authResponse) {
var imgURL="http://farm4.staticflickr.com/3332/3451193407_b7f047f4b4_o.jpg";
FB.api('/album_id/photos', 'post', {
message:'Test',
url:imgURL
}, function(response){
if (!response || response.error) {
console.log(response);
} else {
alert('Post ID: ' + response.id);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_stream'});
});
I've created the app. Added the API ID when including the Javascript.
When running I get a pop up asking me to log in, and it seems to log me in without problems. But it returns an error when checking for a response or response.error.
Any advice.
Not sure if this is still a problem for you, but I've been looking into the same thing recently and I believe that, for this type of upload, FB basically requires source to be the image data itself, not a URL to the image. (See the create photos section on https://developers.facebook.com/docs/reference/api/album/ - it indicates that the source paramater must be multipart/form-data.)
So you have a few workarounds:
1) You may be able to do it from JS if you can create a custom Open Graph Object. I haven't tried this yet, but https://developers.facebook.com/docs/opengraph/usergeneratedphotos/ looks like it expects a URL rather than the post data itself.
2) If the image is originating on the user's computer, you can create an HTML form that submits to FB and have the image go directly from the user to FB without ever hitting your server. This blog post shows an example of that: https://developers.facebook.com/blog/post/498/
3) If the image is originating in your system, you can do a POST from your server to FB that mimics the above form. If it's somewhere else online (such as Flickr), you can download it to your system first and then POST it to FB. You'll have to include an access_token in the request. I don't know what language / framework you're using on your server, but there's probably a library to make creating POST requests easier.
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.