i want to create a post that will appear on the recipients 'Visitors Post'. As a test, I am trying to target this page: https://www.facebook.com/SenatorMikulski/. I went to this site http://findmyfbid.com/ to get the user id, which is 142890125771427. Then I am doing this in my code;
ezfb.api('/me/feed','post',{message:'We will miss you',to:[142890125771427]}, function (res) {
debugger
});
The post succeeds but it appears on my timeline and not on the Senator's Visitor Post. What am I doing wrong?
Ok i figured out my mistake. The end point should be 142890125771427/feed
Related
I am trying to integrate facebook bot for my business page and followed this
Copied js code given to setup webhook and created a .js file... but when i tried to verify and save the message it showed was "The URL couldn't be validated. Response does not match challenge, expected value = '1227072936', received=' app.get('/webho...'".
I am .net developer and have no idea of javascript coding.
Can anyone suggest me where i am going wrong?
This is my code while verify web hook in java
i just create a serlvet with dopost method and then git the request parameters like below .. sure you have something like that in .net
String token = req.getParameter("hub.verify_token");
if (token != null && !token.equals("")) {
resp.setContentType("text/html");
if (token.equals("{verified_token}")) {
String challenge = req.getParameter("hub.challenge");
System.out.println("I am WebHock Verification --------> ");
}
}
{verified_token} is the token i added while verify my webhook url
the webhook url in the image below replaced by my serlvet URL :
I hope that help you
I've a facebook application and I'm using a Feed and Share Dialog popup to post an image on my personal profile. My goal is to tag a friend of mine (instead of posting it on his timeline, I can not change this behaviour for a customer request - considered less spammy).
So, the question is, is there a way to tag a friend in the post? According the API of Feed and Share Dialogs it's not possible, but how can I do that?
Here's the code.
var sIdPersonalProfile = [my personal id profile];
var sIdFriendProfile = [my friend id profile];
var hFacebookData = {
method: 'feed',
display : 'popup',
name: 'NAME_APP',
caption: 'CAPTION_APP',
description: 'DESCRIPTION_APP',
picture: 'URL_APP',
to: sIdPersonalProfile
};
FB.ui(hFacebookData, callback);
thanks in advance.
Assuming you have already figured out how to POST the image to your personal profile. Then, to tag yourself or someone else is quite easy. You need to issue POST request to one of the following urls:
https://graph.facebook.com/PHOTO_ID/tags/USER_ID
https://graph.facebook.com/PHOTO_ID/tags?to=USER_ID
or, if you need to tag more than one user you need to pass an array of user ids...
'https://graph.facebook.com/PHOTO_ID/tags?tags=[{"tag_uid":"1234"}, {"tag_uid":"12345"}]`
This operations will require the following permissions are passed in the scope parameter...
user_photos
publish_stream
You can also specify some extra parameters such as the coordinates of the location of the tag in the image and a tag caption. For more info, check out the Facebook Developer Photo API to publish tags
I have been using Meteor for two weeks, I am trying to add functionality to send an email once the user account has been created. I have looked at several tutorials on the Accounts.onCreateUser() function. Here is the code below.
if(Meteor.isClient{
....some code here.....
Accounts.createUser({
..... Insert some options ......
}, function(error){
..... some More code here ......
});
}
if(Meteor.isServer){
Accounts.onCreate(function(options, user){
...... Do the required .......
});
}
It seems like it is according to the several tutorials that I have been using.
I have tested out the code and but the onCreate for the account is always returning 'Internal server error' and I can't find out a cause for it. Is this the way that I am supposed the Accounts.onCreate() callback for the form?
Also is there a debugging functionality if so I can further track the code down?
Thanks
Your code says onCreate instead of onCreateUser. Maybe that's a typo? Also make sure it is returning a user document. You can always add a console.log to test if the function is being called with the right parameters.
I'm stuck with sharing and commenting Facebook posts from my website.
Look.
In Twitter we can reply a tweet simply by a link
https://twitter.com/intent/tweet?in_reply_to=35782000644194304
or
we can retweet the tweet by this link
https://twitter.com/intent/retweet?tweet_id=35782000644194304
it's so easy, after clicking you redirecting to twitter where you can do this, and i like it.
With facebook posts it is not so easy.
I have Facebook posts (copies of posts, i parsed them before and saved to my DB, ID of that posts I saved too) at my website and I'd like to share/comment/like this posts. Maybe Facebook have the links like twitter, or some another way to do it, I don't know, but i spend all day to find solution and I failed.
Maybe it is possible to create links like this:
http://facebook.com/ID_OF_THAT_FB_POST/share
or
http://facebook.com/ID_OF_THAT_FB_POST/comment
and.. after clicking the link, it redirects to facebook page, where you can share this post or comment?
Well let me see if I understand, If you want to SHARE/COMMENT/LIKE a post on Facebook, from your website then you can use the Graph API, POST, connection section.
https://developers.facebook.com/docs/reference/api/post/
This allows you to create a comment and a like, having the right access_token and the stream_publish permission.
Create:
You can write to the POST_ID/comments connection to post a comment to the post by issuing an HTTP POST request with the publish_stream permission and following parameters.
So you have yo make an HTTP POST request to http://graph.facebook.com/POST_ID/comments?message=HELLO+WORLD&access_token=YOUR_ACCESS_TOKEN
same thing for the like:
make an HTTP POST request to http://graph.facebook.com/POST_ID/likes?access_token=YOUR_ACCESS_TOKEN
with Javascript SDK would be something like this :
var postID='POST_ID';
var msg = 'Comment this post';
FB.api('/'+postID+'/comments', 'post', { message: msg }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
If you want to share the there is no API documentation for that, but you can use something like this:
<script type="text/javascript">
function sharePost(){
var page = 'https://www.facebook.com/permalink.php?story_fbid=POST_ID&id=PAGE_ID';
var sharer= 'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(page);
var w=660;
var h=460;
var sTop=window.screen.height/2-(h/2);
var sLeft=window.screen.width/2-(w/2);
var sharer= window.open(sharer,"Share","status=1,height="+h+",width="+w+",top="+sTop+",left="+sLeft+",resizable=0");
return false;
}
</script>
<a onclick="sharePOST()">SHARE POST</a>
Do not think facebook yet has such kind of api, though you may look up the iframe url structure for any kind of social widget and try to play around. Here is the list you may look it up https://developers.facebook.com/docs/guides/web/#plugins. Take in consideration that share button is deprecated in favor of like. Also I would rather escape heavy code customization and trying to use API as much as it possible, this would help avoid future incompatibilities while facebook's evolution)
I am using the HTML5 version of Facebook Comment in my website. I have my own Facebook APP Id.
Using Graph-API, and FQL (I think this is how to do it), I want to list all the Comments posted in my website.
Example -
Page Title1
--Comment1
--Comment2
--Comment3
Page Title2
--Comment1
--Comment2
--Comment3
Page Title3
--Comment1
--Comment2
--Comment3
etc.
Please help me out.
It is possible, in two different ways, as long as you have a fixed set of sub-pages you want to fetch comments from.
If you have a large amount of sub-pages, or a variable amount, then you don't have a good scalable solution - and many have been looking for one:
Facebook fb:comments Graph API
How to display recent comments from Facebook Comments social plugin?
Facebook FQL query to return all comments against an application
Retrieve all comments with FQL by application ID
Facebook FQL query to return all comments against an application
fql query to get comment count no longer working
http://facebook.stackoverflow.com/questions/10023179/retrieve-all-the-comments-posted-using-fql
For a Fixed set of sub-pages in your website, you can either use a batch request, or an FQL query.
Batch Request
First, you need your access token. Just enter the following as a url in a browser (credit to this website ):
https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=APP_ID&client_secret=APP_SECRET
And this is the javascript jquery code to make a batch request to fetch comments from several urls at once:
$.ajax({
url: 'https://graph.facebook.com/',
type : "POST",
data: {
access_token : 'YOUR_APP_ACCESS_TOKEN',
batch : '[ \
{"method":"GET","relative_url":"URL1"}, \
{"method":"GET","relative_url":"URL2"} \
]'
},
success: function(data) {
jdata = JSON.parse(data);
$.each(jdata, function(index,value){
jdata[index].body = JSON.parse(value.body);
console.log(value.body);
});
// Do whatever you want with jdata
}
});
FQL
inspired from this post
FB.api({
method: 'fql.query',
query: 'select text from comment where object_id in (select comments_fbid from link_stat where url="URL1" or url="URL2")'
}, function(response) {
// Do something with results
});
Conclusion
Because of this limitation of Facebook, I plan to switch to disqus.com, which apparently supports this feature (As you can see from this blog, for example. (search for 'recent comments')
Rather than list all the comments on your site, Facebook wants you to implement code to get notified when a new comment is posted anywhere on your site.
To make this happen, you have to put some Javascript into the page where the comment is posted to also notify yourself:
window.fbAsyncInit = function(){
console.log("subscribing to comment create");
FB.Event.subscribe('comment.create',function(response){
console.log("facbeook comment created: " + JSON.stringify(response));
var commentQuery = FB.Data.query('SELECT fromid, text FROM comment WHERE post_fbid=\'' + response.commentID + '\' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url=\'' + response.href + '\')');
FB.Data.waitOn([commentQuery], function () {
console.log("Facebook comment: " + JSON.stringify(commentQuery));
});
});
};
Where rather than just logging the comment to the console, you would need to implement some AJAX that would send the comment back to your site where you could store the comment in your database, or send yourself an email notifying you that the comment has been posted.
Reference: Facebook Comments Plugin
Say your website is http://mywebsite.com/blog.php?id=3 and you have a facebook comments plugin on it,
you can access comments this way
https://graph.facebook.com/comments/?ids={YOUR_URL}.
{YOUR_URL} becomes http://mywebsite.com/blog.php?id=3
Example 1: (Comments plugin installed on developers facebook doc website )
website: http://developers.facebook.com/docs/reference/plugins/comments
fetch comments: https://graph.facebook.com/comments/?ids=http://developers.facebook.com/docs/reference/plugins/comments
Example 2:
website: http://techcrunch.com/2011/04/08/the-seven-most-interesting-startups-at-500-startups-demo-day/
fetch comments: https://graph.facebook.com/comments/?ids=http://techcrunch.com/2011/04/08/the-seven-most-interesting-startups-at-500-startups-demo-day/
Check this too
Sample code for pulling comments can be found on this blog post