Facebook JS SDK - Posting a Photo "Inline" - facebook-javascript-sdk

I have success with the post using the below code example. But, the photo is not displayed "inline" on the post. Instead, it is shown as an attachment (paperclip) which, when clicked, opens the image.
FB.api('/page_id/photos', 'post',
{ message: 'the message', url: 'http://www.mysite.com/myimage.jpg' },
function(response) { });
Does anyone know of a way, with the JS SDK, to post a photo inline?

Related

Facebook FB.ui dialog iOS Web App unclosable

I have FB.ui working well, I can share whatever info I need to share. However the issue is that it's being rolled into a Web App (This "add to home screen") for an ipad. Whenever the dialog opens, it's opened full screen, and once it's shared there is no way to close the opened dialog.
<input type="button" onclick="share_prompt()" value="Share" />
function share_prompt()
{
FB.ui(
{
method: 'feed',
display: "iframe",
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.');
}
}
);
}
I've changed the "display" property to everything possible, but the docs say that it defaults to a "touch" display in web apps.
Also, to make it even more frustrating, the response doesn't fire when in web app mode. Only in the browser window.
Any ideas?
This is the way I solved this:
if(navigator.standalone){
new_url = 'https://www.facebook.com/dialog/feed?'+
'app_id=XXXXXXXXXXXXX'+
'&display=popup'+
'&caption='+fbName+
'&picture='+fbPicture+
'&description='+fbDescription+
'&link='+fbLink+
'&redirect_uri=http://myurl.com/mycontroller/#post_id';
window.open(new_url,'_self');
} else {
//do the normal way
}
This way you can have a redirect url and you can send the post id back to your app if you need it. Hope this answers your question if you still didn't find a way to solve it.

Google plus api : Share image

Is there any way to share images with description using Google+ public api?
For facebook I use
FB.api('me/images', 'post', {
message: 'My description - http://www.mywebsite.com/mypage',
url: 'http://www.mywebsite.com/path/to/my/image.jpg'
}, function (r) {
alert('SUCCESS');
});
For Google+, I juste have
https://plus.google.com/share?url=https://www.mywebsite.com/mypage
but this just gives a small capture of the image with the information contained in the open graph tags. I want something that gives the same result as if you clic on "Photos" on Google+ and then drag & drop an image then add a description.
Thanks,

Jquery trigger when PDF file downloaded

I am using wicked_pdf plug-in for generating pdf. I am showing message and spinner when user click on pdf link and i want to hide that when pdf is generated and pushed to browser for download/show. I have added jquery code on body onload which will not execute. Is there any other way to trigger jquery function when pdf file pushed to browser?
This is a rather complicated issue, but can be solved nicely if you are willing to use jQuery plugins. http://jqueryfiledownload.apphb.com/ is a plugin that can do exactly what you need if I understood you correctly.
My frontend code looks like this
$.fileDownload('/Content/Print', {
successCallback: function (url) {
$("#PrintingMessage").dialog('close');
},
failCallback: function (responseHtml, url) {
$("#PrintingMessage").dialog('close');
if (responseHtml.indexOf('Error403') != -1) {
$("#PrintingFailedMessage").html("Error 403.");
} else if (responseHtml.indexOf('Error500') != -1) {
$("#PrintingFailedMessage").html("Error 500.");
}
$("#PrintingFailedMessage").dialog({ modal: true });
},
httpMethod: "POST",
data: $('#PublishForm').serialize()
});
And my backend does this at the end of the process. You'll have to translate that yourself :)
Response.SetCookie(new System.Web.HttpCookie("fileDownload", "true") { Path = "/" });
return File(file, System.Net.Mime.MediaTypeNames.Application.Octet, filename);

Loading indicator with dojo XHR requests

I only recently started using dojo and I am doing numerous ajax calls using dojo xhrGet, xhrPost,..etc. Now I have an animated gif image which i want to use to indicate "loading" to the user. I am not too sure how this can be done. Can someone please advise me on this? here is my code,
dojo.xhrGet({
url: registcarturl,
handleAs: "json",
preventCache: true,
load: function(data, ioArgs) {
//DO STUFF WITH data HERE
},
error: function(error) {
alert("sorry ! an error occurred while adding to the cart with ajax");
}
});
How do i get my loading gif file into the interaction? Thank you.
Have a look at dojox.widget.Standby: http://dojotoolkit.org/reference-guide/dojox/widget/Standby.html
To give you an example, define the widget.Standby
<div jsId="basicStandby1" dojoType="dojox.widget.Standby" target="yourDomTarget">
After calling dojo.xhrGet, show it:
basicStandby1.show();
And when you receive your answer, hide it:
basicStandby1.hide();

Rails 3 loading page with ajax animation

i have already read this topix : "http://stackoverflow.com/questions/4820637/how-do-i-perform-an-ajax-request-to-the-create-action-on-loading-a-page-in-rails" but it doesn't respond to the question..
I want to make a loading animation into my rails 3 app cause the server takes time to send email and do some other calculation so the user experience is not so good...
I have read this tutorial : http://www.marketingformavens.com/blog/create-a-page-loading-animation-with-ruby-on-rails-and-ajax but it's for rails2 (remote_function doesn't exist anymore in rails 3).
I wonder if someone can tell the way i should do so :
-> having a nice animation loaded onto the screen when the user click on an action (like create, or update)
Thank's a lot.
Hope to find a answer...
If I understand you want to load an animation while your action is done in ajax. Just use the jQuery API to call your controller actions in Ajax and use callbacks to stop your animations :
$("#myaction").click(function(){
//write your animation code here
$.ajax({
url: "http://localhost:3000/yourcontrolleraction",
dataType: "json",
type: "POST",
processData: false,
contentType: "application/json",
data: yourdata
success: function(){
//stop your animation here
}
})
});
For more on using jQuery Ajax with Rails I suggest your read this excellent post : http://blog.project-sierra.de/archives/1788