facebook jssdk fb.ui picture not showing in dialog - javascript

I've got this facebook(and yes-the php variable get parsed into a url correctly)
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'My Social Status',
caption: 'This Is My Social Status',
picture: 'http://server.com/<?php echo $finalimagepath; ?>',
description: 'My social status lets you create a profile pic that tells your real mood. ',
href: 'http://apps.facebook.com/app'
},
action_links: [
{ text: 'My Social Status', href: 'http://apps.facebook.com/app' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>

you have to configure the link: parameter for some reason. Not sure how the two are related, and trying to figure out a way to get the picture to show without a link parameter.

Related

How to post an attached link to a facebook group?

How can i post my link attachment to a group feed on facebook with this? I think i've done it wrong.
function post_to_group() {
FB.api("/group_id/feed", 'post', {
message: 'My Sample Post',
attachment: {
name: 'Article Name Slugs',
href: 'http://mylink.com/article-name-slugs/'
}
},
function(response) {
if (!response || response.error) {
console.log('Error occured: ', response.error);
} else {
alert('Post ID: ' + response.id);
}
});
}
here's my reference to what I've done:
Facebook - Posting to a Group page
but this shows an error in both my work and the one i reference to -
{message: "(#200) The user hasn't authorized the application to
perform this action", type: "OAuthException", code: 200}
FB.ui(
{
method: 'stream.publish',
from: myId,
to: groupID,
attachment: {
name: 'Post to a group Test',
href: '...'
}
});

Facebook JS - FB.api() only posts message, not media attachment

I'm trying to post to the active users wall with a mp3 attachment. It works fine from
Facebook's Test Console (see below), but when I call it from my mobile app, It only posts the message. What am I missing here :(
Facebook's Test Console: http://developers.facebook.com/docs/reference/rest/stream.publish/
Here is my JS...
Login
FB.login(
function(response) {
if (response.authResponse) {
alert('logged in');
} else {
alert('not logged in');
}
},{ scope: "email,user_likes,publish_stream,offline_access" } //added offline_access to see if that was the problem
);
Post to wall with attachment
var attachment = {
'message': 'testing',
'attachment': {'media': [{
'type': 'mp3',
'src': 'http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3',
'title': 'Test Title',
'artist': 'My Artist',
'album': 'My Album' }]}
};
FB.api('/me/feed', 'post', attachment, function(response) {
if (!response || response.error) {
alert(response.error.message);
} else {
alert('Post ID: ' + response.id);
}
});
var attachment = {
'message': 'testing',
'source': 'http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3'
};
This will post the mp3 to your feed allowing a user to click a play button inline. See working example here: http://jsfiddle.net/dmcs/aggJc/1/
As you will note, that when you POST data to the Graph API, the formatting is different than when you GET the same object back. Posting is kinda shorthand notation version and the Getting is the long hand.

How to detect Facebook share success? with Javascript

This code is sharing facebook but I want How to detect facebook share success How Can I do that with javascript
u = location.href;
t = document.title;
var myWindow = window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
return false;
It seems you should use FB.ui
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);

How do you autopublish with FB.UI?

I have the stream_publish permission but it still pops up a dialog and there doesn't seem to be any way to pass in an autopublish bool (like it was before the graph api).
EDIT: Also tried offline_access with stream_publish.
Any ideas on how to get this to work?
function streamPublish(imageUrl, imageHref, attachName, attachHref, attachCaption) {
FB.ui(
{
method: 'stream.publish',
message: '',
attachment: {
name: attachName,
caption: attachCaption,
description: (
''
),
href: attachHref,
media: [
{
type: 'image',
href: imageHref,
src: imageUrl
}
]
}
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
}
);
}
http://www.takwing.idv.hk/tech/fb_dev/jssdk/learning_jssdk_12.html
The following will autopublish if you have the permissions unlike FB.UI :)
function publishPost(session) {
var publish = {
method: 'stream.publish',
message: 'is learning how to develop Facebook apps.',
picture : 'http://www.takwing.idv.hk/facebook/demoapp_jssdk/img/logo.gif',
link : 'http://www.takwing.idv.hk/facebook/demoapp_jssdk/',
name: 'This is my demo Facebook application (JS SDK)!',
caption: 'Caption of the Post',
description: 'It is fun to write Facebook App!',
actions : { name : 'Start Learning', link : 'http://www.takwing.idv.hk/tech/fb_dev/index.php'}
};
FB.api('/me/feed', 'POST', publish, function(response) {
document.getElementById('confirmMsg').innerHTML =
'A post had just been published into the stream on your wall.';
});
};

Using Facebook Graph to simply post a wall message with just javascript

In Facebook how can I post a message onto a user's wall saying "I scored 8/10 on objects game" then a URL?
I really don't want to have to use the full API, as I don't want to handle user login details. I don't mind if Facebook needs to authenticate and then post the message.
Is it possible using the new Graph API and JavaScript?
Note 4/16/2011: stream.publish seems to have been deprecated, There's a new way to do this: http://developers.facebook.com/docs/reference/dialogs/feed/
You can use something like this to publish to a wall, the user will need to confirm before it get sent.
Don't forget that you'll need to use FB.init and include the JS SDK link.
function fb_publish() {
FB.ui(
{
method: 'stream.publish',
message: 'Message here.',
attachment: {
name: 'Name here',
caption: 'Caption here.',
description: (
'description here'
),
href: 'url here'
},
action_links: [
{ text: 'Code', href: 'action url here' }
],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
Post on wall will show a dialog box to share the message on wall or not. But I wanted to post the message silently on user's wall, assuming that user had already given "Post on wall" permission.
FB.api('/me/feed', 'post', {
message:'my_message',
link:YOUR_SITE_URL,
picture:picture_url
name: 'Post name',
description: 'description'
},function(data) {
console.log(data);
});
Considering that you have a proxy to make cross domain calls, you can simply do this...
In this example, YourProxyMethod takes a jQuery.ajax like hash, makes a server side post & returns the response in success/error callbacks. Any regular proxy should do.
The trick is to include app_id and access_token in the URL irself.
Also, your FB app should have sufficient permissions to make this call.
YourProxyMethod({
url : "https://graph.facebook.com/ID/feed?app_id=APP_ID&access_token=ACCESS_TOKEN",
method : "post",
params : {
message : "message",
name : "name",
caption : "caption",
description : "desc"
},
success : function(response) {
console.log(response);
},
error : function(response) {
console.log("Error!");
console.log(response);
}
});

Categories

Resources