I'm interested to create a post on my page or my feed with few images from my album and some text which will contain some message and some link / handle ( to facebook friend or page )
For now i've tried to create an album, add few images to it but i don't have almost no control of what th description is going to be.
FB.login(function () {
FB.api("/me/accounts", function (response) {
FB.api(
"/usetoken/albums",
"POST",
{
"name": "My Album",
"message": "Some Message",
"access_token": response.data[0].access_token
},
function (response) {
debugger;
if (response && !response.error) {
debugger;
/* handle the result */
}
}
);
});
}, { scope: 'publish_actions,user_photos,manage_pages' });
function post_image() {
FB.api(
"/albumid/photos",
"POST",
{
"url": "imageurl",
"access_token": access_token
},
function (response) {
if (response && !response.error) {
debugger;
/* handle the result */
}
}
);
}
If you really want to publish rich content, you should use Notes.
When you create an album, it will be shown as a status of your page/profile. The status message of that status will be the album description. So you can insert your message into the album description, and you should be ok.
Related
I'm trying to post on a test Facebook page, but it wouldn't work here's what I did:
window.FB.api(
'/https://graph.facebook.com/700757323715208/feed',
'POST',
{message:"Hello Fans", access_token:"{access_token}"
},
function(response) {
console.log(response) }
);
and it's rendering this:
{id: "2568244933261615", url: "https://graph.facebook.com/700757323715208/feed"}
But it's supposed to render something like this :
{
"id":"1116692661689527",
"post_id":"546349135390552_1116692711689522"
}
Correct version:
window.FB.api(
'/me/feed',
'POST',
{message:"Hello Fans", access_token:"{access_token}"
}, function(response) {
console.log(response);
});
You do not need the Page ID, you have to use a Page Token of that Page anyway.
(I am using IONIC with the plugin cordova-plugin-facebook4) With this code:
facebookConnectPlugin.api('/me?fields=email,name,gender,picture&access_token=' + authResponse.accessToken, ["public_profile"], function (response) {
I am getting this response:
{"email":"xxxxx#hotmail.com","name":"xxxx Molina","picture":{"data":{"height":50,"is_silhouette":false,"url":"https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=2076928542548945&height=50&width=50&ext=1539748506&hash=AeRdIrWpWFtDY_k8","width":50}},"id":"2076928542548xxx"}
how can get the gender and date birthday of the actual user?
Try this,
facebookConnectPlugin.api("<user-id>/?fields=id,email,gender,birthday",["public_profile","user_birthday"],
function onSuccess (result) {
console.log("Result: ", result);
/* logs:
{
"id": "000000123456789",
"email": "myemail#example.com"
}
*/
}, function onError (error) {
console.error("Failed: ", error);
}
);
I'm creating an app to publish photos in Facebook. With my code I receive this error:
{"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}
I know that the login is ok....but after the upload give me this error...
Someone can help me please?
ciaopoint2.Globals.imagefinal = 'data:image/jpg;base64,'+canvas.toDataURL("image/jpg");
//Verifico lo Stato del Login
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
FB.api(
'/photos',
'POST',
{
message: 'CiaoPoint ti ringrazia',
source: ciaopoint2.Globals.imagefinal
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
}
else {
FB.login(function(response) {
if (response.authResponse) {
FB.api(
'/photos',
'POST',
{
message: 'CiaoPoint ti ringrazia',
source: ciaopoint2.Globals.imagefinal
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
}
else {
alert("Non puoi loggarti in Facebook");
}
}, {scope: 'email'});
}
});
I've been trying to post some data from my webpage directly to a facebook group wall. Is is possible to achieve?
Here's a code i used:
$.getScript('//connect.facebook.net/en_UK/all.js', function(){
FB.init({
appId : myAppId,
xfbml : true,
version : 'v2.0'
});
FB.api('/groupId/feed', 'post', { link: 'linkToMyPage', name: 'Name' } , function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Success!');
}
});
Any help will be appreciated!
By comparing your code against Facebook's sample code, I noticed that you need to capitialize "POST", also their code nests { link: 'linkToMyPage', name: 'Name' }' within an Object block. So I am thinking you should replace the link and name with something similar to:
"object": {
"link": linkToMyPage,
"name": 'Name'
}
Here is the API doc, which describes how to publish to a Group feed.
I have been using Graph API along with javascript facebook sdk to make posts on users wall. The code looks like this
function graphStreamPublish(){
showLoader(true);
FB.api('/me/feed', 'post',
{
message : "Sample Message",
link : 'link url',
picture : 'image url',
name : 'app name',
description : 'Test stuff'
},
function(response) {
showLoader(false);
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}
Can this piece of code be used to post on users timeline as well or is there something else I need to do?
The following code works. ( Notice the 'publish_actions' permission used at the end).
FB.login(function(response) {
// handle the response
if (response.status === 'connected') {// Logged into your app and Facebook.
FB.api('/me/feed', 'post',
{
message : "Sample Message",
name : 'app name',
description : 'Test stuff'
},
function(response) {
if (!response || response.error) {
alert(response.error);
} else {
alert('Post ID: ' + response.id);
}
});
}
}, {scope: 'public_profile,email,publish_actions'} );
Years ago, you could use field TO with user id, nowadays you cant post to users timeline, but you can use TO field with an ID, for posting on groups, events or pages .