post big image to facebook wall with facebook javascript api? - facebook-graph-api

How can I post a big image along with my message to my facebook wall?
With the below code it only displays a min image?
And if I post a message and image from inside facebook, then that image is the full width of the timeline, how can I do that with the below code?
function postonwall(){
FB.api('/me/feed', 'post',
{
message : "testtext.",
link : 'http://www.mydomain.se',
picture : 'http://www.mydomain.se/image.jpg',
name : 'somename',
description : 'sometext !'
},
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
//alert('Post ID: ' + response.id);
alert('Success: Content Published');
}
});
}
Or what do I have to do to post a big image, if it doesnt work with this?
Any input appreciated, thanks!

From what I've researched, the only way to post large images to a users wall/timeline is through the use of "User Generated Photos in the Open Graph"
Go here to learn more:
https://developers.facebook.com/docs/opengraph/usergeneratedphotos/

Related

facebook unsupported post request

I have logged in a user to my app from FB.login now I want to post to the user timeline on the behalf of user. I want to upload a video to the user timeline. I am doing something like:
FB.api(
`/${user_id}/videos`,
"POST",
{
"file_url": video,
"description": description,
"thumb": video_thumbnail,
"title": title,
},
function (response) {
console.log("fb response")
console.log(response)
if (response && !response.error) {
/* handle the result */
console.log("video upload response")
console.log(response)
}
}, {scope: ['user_videos', 'user_actions.video']});
When I do this it is giving me error saying code: 100
fbtrace_id: "F1BDJWtcTXl"
message: "Unsupported post request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api"
type: "GraphMethodException"
Why I am getting this error ??
Help is appriciated ..
Thank you
Use /me/videos instead of /${user_id}/videos and use single (or double) quotes instead of "`".
Also, you need publish_actions only, and you need to use the scope parameter with FB.login. FB.api is just an API call.
Here´s an example for the login: http://www.devils-heaven.com/facebook-javascript-sdk-login/
And here´s the link to the docs for uploading videos: https://developers.facebook.com/docs/graph-api/reference/user/videos/#Creating
Someone suggested that the App may be in sandbox/dev mode, no sure why this should be a problem but here´s the thread: How to fix "Unsupported post request" when posting to FB fan page?

Android webview shows blank screen after sharing the content on facebook wall ? I am using javascript sdk to share the Post

I am using the javascript sdk to share content on a Facebook wall:
FB.ui({
method:'share',
display: 'touch',
href: 'www.adarshkr.com',
redirect_uri:'www.adarshkr.com'
},
function(response) {
if (response && !response.error)
{
alert("shared");
window.reload();
console.log(response)
}
else
{
FB.init();
}
});
Upon sharing the content its not taking to URL which is specified in redirect_uri. In Android webview, upon sharing the content i am getting the blank screen.. I am not getting response from the facbook.

Facebook post page feed as page admin

var message = 'test';
var picture = 'http://l.yimg.com/f/i/tw/ks/show/120604_mntl01.jpg';
var link = 'https://www.youtube.com/watch?v=BIl8Px1ds3c';
var name = 'great';
var description = 'des';
FB.api('/1437247769881131/feed', 'post', {message: message, picture: picture, name: name, description: description },function (response){
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
I tried posting a test message to my fan page wall , but it become a visitor post(on left)
How could i post to the wall , if i change my admin to fan page admin ,it pop up a dialog
[You're using Facebook as a Page]
[To continue, you'll need to switch from using Facebook as 談政宏 to using Facebook as 談政宏.]
So i change back to person admin , but i can only post a visitor post
How can I post as Page Admin ?
You just need to use a Page Token to post "as Page". Right now you are using a User Token so it will get posted "as User". Information about Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/

Fetch New Open Graph Image - Facebook

I have the following problem.
I have a social plugin on a particular website, and every day the thumbnail images (Image Open Graph) are changed.
Every day I need to enter the following url:
https://developers.facebook.com/tools/debug/
And insert my url, and click "Fetch new Scrape Information".
To update the facebook Open Graph Image.
Does anyone know how to automate this process?
The Solution:
Facebook - Open Graph not clearing cache
Add to your page:
$.post(
'https://graph.facebook.com',
{
id: '<?php echo $url; ?>',
scrape: true
},
function(response){
console.log(response);
}
);

How to choose the image size when using FB.api(me/friends), into Facebook Graph API?

I'm using that snippet below to get info of my contacts, works fine, I just need to know how to change the size of the picture I get, currently I'm getting a very small pic. I searched through Facebook docs and found nothing.
FB.api('/me/friends', { fields: 'id, name, picture', limit: 3 }, function(response)
{
if (response.error)
{
alert(JSON.stringify(response.error));
}
else
{
alert("Loading friends...");
console.log("fdata: " + response.data);
response.data.forEach(function(item)
{
// feeding my html
});
}
});
Thanks!
Ps.: I'm using a Phonegap plugin to use Facebook API. Probably, the JS methods I'm calling are calling Java methods, so, I don't know which especifically API I'm using, but seems to me the default Graph Api.
I use /user_id/picture?type=large for profile pics.
http://developers.facebook.com/tools/explorer/135669679827333/?method=GET&path=732484576%2Fpicture%3Ftype%3Dlarge
refer to http://developers.facebook.com/docs/reference/api/#pictures
in your case do not call the pictures of the friends, use the id instead
in your html build the image
<image src="https://graph.facebook.com/user_id/picture?type=large&return_ssl_results=1" />
Example:
<div id="friends"></div>
<script>
FB.api('/me/friends', { fields: 'id, name', limit: 3 }, function(response)
{
if (response.error)
{
alert(JSON.stringify(response.error));
}
else
{
alert("Loading friends...");
console.log("fdata: " + response.data);
response.data.forEach(function(item)
{
document.getElementById('friends').innerHTML+='<image src="https://graph.facebook.com/'+item['id']+'/picture?type=large&return_ssl_results=1" />';
document.getElementById('friends').innerHTML+='<br />'+item['name']+'';
});
}
});
</script>
You can go with either of the following 4 based on your needs
FB.api('id?fields=picture&type=large');
or
FB.api('id?fields=picture&type=small');
or
FB.api('id?fields=picture&type=square');
or
FB.api('id?fields=picture&type=normal');