I want to create unpublished image post on facebook and then edit the message attached to it.
I can create an image by doing:
/me/photos
url: somewhere
published: false
caption: 'abc'
This, due to documentation should return
Struct {
id: numeric string,
post_id: string,
}
But it doesn't return post_id. If published is set to false the post_id is omitted. When I visit created photo on facebook I can edit attached caption and other parameters of the photo. But when I try to do it trough API I can only edit very limited amount of parameters, described here:
https://developers.facebook.com/docs/graph-api/reference/photo/#Updating
I also tried different approaches, of which most promising was to post unpublished photo, then create unpublished post with image attached. Since I'm trying to post to a page I'm using this endpoint:
https://developers.facebook.com/docs/graph-api/reference/v2.5/page/feed
/me/feed
caption: 'abc'
published: false
object_attachment: (id-from-previous-request)
If I could do it like this I could later edit the message, and the post would look the same as when using /me/photos normally.
I cannot do
/me/feed
caption: 'abc'
published: false
url: somewhere
Because this results with link post(and requires link parameter as well), which is different in look from image post.
I cannot figure what I am doing wrong - I just want to create unpublished post with attached image and then edit it. It's possible trough webpage, but all my attempts trough API have failed.
The related post_id for photo_id is always generated like this(for page):
page_id + '_' + photo_id
In case the photo was posted into different edge then instead of page_id corresponding id is used, for example it would be user id, if it was posted onto edge user/photos.
This behavior isn't documented anywhere where I could find it, nor it is guaranteed to work in the future. I contacted facebook support yet they didn't clarify if it's intended. They only said that it's by design that post_id is not returned.
Related
On some sites users have account numbers, on others nicknames; one can represent the other and vise-versa. Or not. On some sites when the username is changed, all the links in their uploads, posts, and comments break completely. KAT.CR is one of those sites. Which is weird because there is a corresponding alphanumeric hash, it just isn't tied to the nickname. This may be leftover from when changes to ones name led to an update, not a "broken user link." In fact this question was asked there first snd a staff member responded that the functionality was withdrawn. No reason was given. This is just an example, there are lots of sites that do this, or make other changes that cause links to break.
Rather than linking to static destination, I would like to write a script that
1. queries a database or subdomain for a pre-specified user id
2. returns the current username,
3. runs a redirect script to the updated profile page for the current user.
If it was my site and I wished to link to my profile here, for example, I would just manually update the url. I used this example because uploads include links in their torrents that cant be updated.
Below is one of several javascripts that appears at the top of every page when logged in a KAT. I am not certain which, if any of the values are a permanent fixture of the account or how/where such a script would search in order to perform the task I described... I would just like to know if the concept is viable.
<script type="text/javascript">
+function(S,p,a,r,e,C,l,i,c,k)
{ S[r]=S[r]||[];S[e]||(S[e]=function(){
S[r].push(Array.prototype.slice.call(arguments)) });
i=p.createElement(a);c=p.getElementsByTagName(a)[0];
i.src=C;i.async=true;c.parentNode.insertBefore(i,c)}
(window,document,'script','_scq','sc', '//a.kickass.to/sc-8cce154.js');
sc('setHost', 'a.kickass.to');
sc('setAccount', '32 digit alphanumeric');
var kat = {
release_id: '8cce154',
detect_lang: 0,
spare_click: 1,
mobile: false
};
var katUser = {
idhash: '28digitalphanumeric',
channel: 'another28digitalphanumeric',
nickname: 'username',
avatar: '//yuq.me/userpics/10/100/userpic.png',
acl: 1,
disable_sounds: 0,
disable_animated_upics: 0 };
</script>
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'm trying to delete an object created by a story, but I'm getting the following error :
(#100) Cannot delete object not created via the API
I used the FB.api in javascript to create a story with news.reads (works), I can delete the story with the ID too. But the object created for the story still exists, I can see it in the Graph API, but cannot delete it.
I want to fix this issue because if I try to create a story with the same article link, if I change the content (the same link refers to a new article), facebook will keep the old settings (title, image and description don't change).
You can force facebook to re-scrape your site when you use scrape=true in your next call:
FB.api(
'/',
'post',
{id: <your article url>, scrape: 'true'},
<your callback function>
);
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
The Facebook new Send Dialog lets people to send content to specific friends. But the API # https://developers.facebook.com/docs/reference/dialogs/send/ said the parameter 'TO' means "A user ID or username".
I wonder is there a method to send message to multiple friends at one time. I tried to set the 'to' as a javascript arrays, but that does not work.
It seems that currently the sdk only takes the first element from the array that is passed to "To" parameter. This is really annoying and no formal explanation is given to this design decision. I'd wish it can take more than one uids or emails, group names etc.
I'm not sure how you're doing it or what you define as "works", but the below kind of works:
Go to the javascript test console here: https://developers.facebook.com/tools/console/
And type in the following, and hit run, it will bring up a send dialog with two names prepopulated. Unfortunately, when you hit send, it goes to an error page (still trying to figure that one out). But still, it does populate the dialog with two names :P
<script>
FB.ui(
{
method: 'send',
to: [5,6],
link: "https://developers.facebook.com",
picture: "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/174597_20531316728_2866555_q.jpg"
},
function(param){
// If they cancel params will show:
// {action:false, ...}
// and if they send the friend request it'll have:
// {action:true, ...}
// and if they closed the pop-up window then:
// param is undefined
}
);
</script>
Seems both ways, direct URL and Javascript don't allow to use a list of ID's , just checked and verified it today
I tried with a comma separated list of IDs, in the 'TO' field, and it worked ;)