I am new to open graph and what i am trying to do is to post a book quote, but without a url. because let's say i want to post a quote from a book using a url from amazon.The problem is that it requires a page that has those og tags, which amazon doesnt.Is there any way to bypass this?
Something like this, but without the book part. Simply put, is there any way of manually specifying the bookname and the thumbnail, instead of using a url to a page that has all that info in a og tag?
function postBook()
{
FB.api(
'me/books.quotes',
'post',
{
body: document.getElementById("quote").value,
bookname: document.getElementById("book").value,
book:"http://samples.ogp.me/344468272304428"
},
function(response) {
alert("Posted !");
}
);
}
What you are trying to do can be achieved using Object API.
Here you will create a quote object using the Object API.
Hope this helps.
Related
I need to pull my news feed and display it in another app. Can I pull my news feed using Facebook API?
Edit: This answer is the result of misinterpretation of the question, as for the correct answer: No, it isn't possible as the news feed isn't a readable and static object that could be read by the API, it's generated for the user as they use it.
I myself never used the API, but with a quick search on their docs(https://developers.facebook.com/docs/graph-api/reference/user/feed/) i could find what you need, the question now is what platform are you using the API?
JavaScript example:
/* make the API call */
FB.api(
"/{user-id}/feed",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
I want to mention tag users/pages(i.e like tagging using # symbol normaly in facebook) in my feed. I have tried the following Graph API,
https://graph.facebook.com/v2.4/feed
with following parameter,
message = "My message #[<user_id>:1:<username>]"
I tried this from graph API explorer, feed is getting posted but the people/page which am tagging is not working, It is not coming as a link it is coming as a plain text.
I want to post a feed like shown in the image i attached, how can I achieve it need help,
Complementing #Tobi's answer. Here's a complete example on how to publish a post and tagging friends:
FB.api(
"/me/feed",
"POST",
{
"message": "This is a test message",
"place": "link",
"tags": "friend_id1,friend_id2"
},
function (response) {
if (response && !response.error) {
console.log(response); /* post id will be returned */
}
}
);
Please have a look at the documentation. You should use the Taggable Friends API:
https://developers.facebook.com/docs/graph-api/reference/user/taggable_friends/
https://developers.facebook.com/docs/graph-api/reference/user-taggable-friend/
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/feed/#publish
You should fill the tags parameter of your post.
https://developers.facebook.com/docs/javascript/reference/FB.ui
With the new update of Facebook API, I've been trying show a dialog for share in timeline, but don't only recognize me the href..
What can I do?
Code:
FB.ui({
name: 'Mejores Huecas',
link: 'www.lasmejoreshuecas.com',
from: '1469541393326876',
caption: 'Las mejores huecas!',
method: 'share',
href: 'https://apps.facebook.com/mejoreshuecas/?fb_source=search&ref=ts&fref=ts',
},
function(response) {
if (response && !response.error_code) {
//alert('Posting completed.');
}
else {
//alert('Error while posting.');
}
}
);
That´s intentional, the Share Dialog reads the data from the Open Graph Tags of the URL and it only takes the href as parameter, as you can see in the docs.
If you want to share custom data, you need to create a separate URL with separate Open Graph tags. After all you share a Link, and the message must be user generated anyway, so you don´t really need additional info - i guess that is why Facebook deprecated the old Feed Dialog.
I was looking for and I am interested is there any way to get just shared facebook description using maybe fb.ui/fb.init or some other way?
EXAMPLE: IMAGE LINK
After the share I could get the description on my website let's say this way:
document.write('The description you've shared!')
So maybe one of you know how to do it or maybe someone knows how to figure it out. I am really looking forward for it! Thanks!
When you use the feed/share dialog using FB.ui, you can specify a callback function that receives the new post's post_id. Then using the post_id, you can retrieve the contents of the post by using an FB.api call. So a basic example:
FB.ui({
method: 'feed',
link: 'https://developers.facebook.com/docs/dialogs/',
caption: 'An example caption',
}, function(response){
FB.api(response.post_id, function(resp) {
document.write(resp.description);
});
}
);
I'm not sure if all the fields are right, but that should give you the basic idea. Let me know if this makes sense :)
Feed and Share Dialogs: https://developers.facebook.com/docs/reference/dialogs/feed/
Post Object: https://developers.facebook.com/docs/reference/api/post/
I am creating a web application that displays a list of images taken from Flickr and I would like a user to login through Facebook and allow them to comment on those images. I was able to get the login/authentication working but I am now having trouble to enable a user to add a comment (as oppose to a Facebook 'post') on a Flickr image and have this activity show up on the user's Facebook profile/feed (i.e "John Smith commented on a link").
Here is what I have so far:
var fbCommentApi = '/me/myappname_ns:comment?access_token=' + fbUserToken + '&method=post' + '&picture=[WEBSITE_URL]' + selectedItemId;
FB.api(
fbCommentApi,
'post',
{ message: txtObj.value },
function (response) {
if (!response || response.error) {
alert("Sorry, there was a problem. Please try again later. [API]");
}
else {
alert("Thank you. Your comment will appear shortly");
hideCommentBox(txtObj);
}
}
);
The above code doesn't create a comment but instead it creates a post on the user's timeline with the URL attached. So when I try to retrieve comments for the WEBSITE_URL item through Facebook Graph...
'https://graph.facebook.com/comments/?id=[WEBSITE_URL]' + itemID
...I end up with empty data being returned.
I have an Action Type called 'Comment' in my Facebook app and that's the action I am using when trying to add the comment.
Thanks in advance and I look forward to your answers.
UPDATE 1: It seems now that if I use Facebook Graph this way.. graph.facebook.com/me/appname_ns:discuss?access_token=[TOKEN]&website=[URL]&method=post
..it would just add an entry to the user's Activity box in their timeline, I didn't even pass a comment or message parameter to the URL as a query string parameter. That could be part of the problem.
UPDATE 2: According to another StackOverflow question, there seems to be no way to get a view of all actions done by all users, it has to be done per user (an API call per user). Therefore another way of handling this particular issue is to save the comments (or whatever action performed) to our own database.
Well, an Open Graph action is not a comment, even if you name it comment …
If you want a real Facebook comment, then either get a reference to an object that actually can be commented upon; or substitute comment with post/link post.