I am trying to send a facebook private message via facebook send dialog in my facebook app, i have a problem while setting the custom image each time user clicks on it, i am sending the parameters as
send msg
and on the function side,
FB.init({
appId: '<?=$this->facebook->getAppID()?>',
xfbml: true,
cookie: true
});
function send_message(user_id, image_name) {
FB.ui({
to: user_id,
method: 'send',
name: 'The Image',
description: 'Description here',
link: 'https://www.something.com/',
picture: '<?=baseurl()?>imagepath/'+image_name
});
}
It works fine without picture parameter, but all the time it uses default image that facebook automatically pick from my link.
please your kind help will greatly be appreciated!
Using HTTPS protocol in picture link (if you do so), you might cause your problems. Take a look at Images not working in FB.ui
Related
I can initiate dialog to send a link to Facebook Messenger. Everything goes fine and recepient gets the message with URL. However, when a message is added in Facebook's UI, only that message is received and URL NOT.
Message field causes link to be ignored in received message
Desktop
I have tried both methods according to
https://developers.facebook.com/docs/sharing/reference/send-dialog/
URL
https://www.facebook.com/dialog/send?display=page&link=https://developers.facebook.com/docs/sharing/reference/send-dialog&redirect_uri=https://www.facebook.com&app_id=<APP_ID>
SDK
window.fbAsyncInit = function () {
FB.init({
appId: '<APP_ID>',
autoLogAppEvents: true,
xfbml: true,
version: 'v11.0',
});
};
FB.ui({
method: 'send',
link: 'https://developers.facebook.com/docs/sharing/reference/send-dialog/',
});
I have tried different SDK versions and different APP IDs.
Mobile
Curriosly so, my setup for mobile works fine, link is received with or without a message.
fb-messenger://share?=<APP_ID>&link=<MY_LINK>
I am really confused as there does not seem much to configure... Thanks in advance for any leads on this.
It has been acknowledged as a bug by Facebook already in May https://developers.facebook.com/support/bugs/201777038410094/
Again reported in July
https://developers.facebook.com/support/bugs/2934678630125393/?join_id=f3c21b71e26d8c
I created an Application in facebook and used in my website.
In my page I am using this function to share a photo.
function postToFacebook(url, img) {
FB.ui({
method: 'feed',
link: url,
picture: img,
name: "Sample name",
description: 'sample desc'
}, function (response) {
console.log(response);
});
}
This function is working and sending a ShareLink on my Time line. But nobody can see my post. I just can see the post on my TimeLine !!!
What it is the problem?
I found out the problem myself.
it is because of the Status of Facebook Application.
Do this setting to fix the problem:
Go to Facebook Developer => You Application => Status & Review => set this option to YES:
"Do you want to make this app and all its live features available to the general public?"
I'm trying to do a basic facebook wall post with an embedded flash object based on the following documentation:
https://developers.facebook.com/docs/reference/dialogs/feed/
I'd like to do this using just a direct URL, like (note parameters get encoded):
https://www.facebook.com/dialog/feed?
app_id=SOME_APP_ID&
link=http://www.myregisteredfbdomain.com/someurl&
picture=http://www.myregisteredfbdomain.com/cfg/media/imagelink.png&
name=Flash%20Test&
caption=Just%20a%20test&
description=A%20Description&
redirect_uri=http://www.myregisteredfbdomain.com/someurl&
source=http://www.myregisteredfbdomain.com/facebook/aflashfile.swf
Although I've also tried it using javascript, with the same result:
<script>
FB.init({appId: SOME_APP_ID, status: true, cookie: true});
function postToFeed() {
var obj = {
method: 'feed',
redirect_uri: 'http://www.myregisteredfbdomain.com/someurl',
link: 'http://www.myregisteredfbdomain.com/someurl',
picture: 'http://www.myregisteredfbdomain.com/cfg/media/imagelink.png',
name: 'Flash Test',
description: 'A Description',
source: 'http://www.myregisteredfbdomain.com/facebook/aflashfile.swf'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
When I do the post under my development fb account, the post shows up fine, and I can click on the icon which displays the flash correctly.
However when I post under my own personal fb account, the post shows with the image only, but no flash activation when I click it - it just goes to the link/redirect link I defined.
Can anyone give me any pointers as to why this might be the case?
Found out why - It's because I'm accessing the post to my personal account through a https connection, which doesn't show the flash - it's linked via a http connection.
Usecase - I have my web application and I want to post some data from my application onto my Facebook wall manually when a user clicks on a Link.
I'm currently using Share Link as follows -
https://www.facebook.com/sharer/sharer.php?u=&t=titleABC" target="_blank">
Share on Facebook
Issue -
I see that a new window opens to post the data. My data also gets posted to my wall, but I want the title to be populated with data from my application rather than asking the user to "Write Something".I want the text box to get populated with the message from the title(t from the url parameter) rather than user editable.
Is there a way to do this.
Sharing your content with Share button is absolutely simple. In my case I did it like this for a button i have in my html with id sharebuttonfacebook
$("#sharebuttonfacebook").click(function() {
var msg = "Hi This is my wonderful website";
FB.ui({method: 'feed',
name: 'MCQ Nation ',
link: 'http://www.mcqnation.com/Trail3/pyramid.php?..dyanmic stuff..' ,
picture: 'http://www.mcqnation.com/Trail3/fbapp2.png',
caption:'CLICK ON THE IMAGE TO GO TO OUR WEBSITE',
description: msg ,
message: 'AAA'});
return false;
});
In addition to this you need to register an app.
Nothing could be simpler.
Just go to http://www.facebook.com/developers/app
and register your new app.
They will give you a simple code that has to be put just after the body which goes like -
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : 'CHANNEL FILE LOCATION', // Channel File This file has just one line which you will find at facebook developers
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
With these two things in place you can Decide what to share on facebook.
Also in the function we have made above you can substitute whatever variables you like hence make it dynamic. Hope this answers your Question.
PS: If it could get better than this you dont need any permission from the user!
The initialization code:
FB.init({
appId: '123456789012345',
channelUrl: 'http://localhost/Some/Url/FacebookChannel',
status: true,
cookie: true,
oauth: true,
xfbml: true
});
The following code is called with an onclick:
FB.ui({
method: 'feed',
name: settings.facebookShareName,
link: settings.facebookLinkUrl,
caption: settings.facebookShareCaption,
description: settings.facebookShareDescription,
message: message,
display: 'popup'
});
This code works fine in FF and Chrome, and mostly works in IE8. The popup is shown and the user can post to their wall, but after submitting, the window doesn't close. It turns white with no further interaction, but must manually be closed by the user.
Why doesn't the window auto-close in IE, and/or are there any workarounds to force the popup to close?
Edit:
This issue may be related to this outstanding bug.
I have the same problem and have never been able to get a response from Facebook for the callback function. I don't see anything in console.log or any alerts I insert in the function.
My solution was to put a URL in FB.ui's redirect_uri that goes to an HTML page with self.close (or window.close). The FB.ui popup redirects there after the user's input and immediately closes. Remember to change your FB app's Site URL setting so it matches the domain the file resides on.
Here's my code, tied to my form's submit action. The function(response) callback is still there but not used. If anyone sees a syntax error please comment on it.
FB.ui ({
method: 'feed',
name: '',
link: '',
picture: '',
caption: '',
description: '',
actions: {name:'',link:''},
redirect_uri: 'http://.../self.close.html'
},
function(response) {
console.log(response);
if (response && response.post_id) {
alert('yes');
self.close();
} else {
alert('else yes');
}
});
The line of code in self.close.html:
<script type="text/javascript">self.close();</script>
A bit old thread, but this might help someone...
The popup will self close if you neglect to put in the "redirect_uri" parameter. (plus, the response callback will now work too)
add return false; to your method call.
onsubmit="someMethod(); return false;"
Not an easy one... but it could work:
First, to force closing the dialog you must pay attention to the response:
See the entire documentation and example here: https://developers.facebook.com/docs/reference/javascript/FB.ui/
Once you have the response you should close the dialog:
See: http://facebook.stackoverflow.com/questions/4646441/how-to-close-a-facebook-sdk-dialog-opened-with-fb-ui
Hope that helps! :)
The pop up will close if you do not give the redirect_uri as mentioned above - as well as if you do not give display (that is, do not give display: 'popup' or display: 'iframe').
Make sure 'http://localhost/Some/Url/FacebookChannel' hosted in the same domain with your app callback url.