Reputation: 753
I am creating an app using Cordova and the Facebook plugin, which means I have the functionality of the Javascript SDK. How can I upload an image using the share dialog. I can share texts or already uploaded images via links. But is it possible to upload images via the share dialog?
I can upload images using the Graph API, but it has the disadvantages that I have to ask for permission to post on the timeline upfront, which is a bad user experience in my opinion.
Thankyou in advance!
Upvotes: 0
Views: 836
Reputation: 5858
I suggest you can use facebook plugin for cordova which covers all of your needs.You can download from (http://plugins.cordova.io/#/package/com.ccsoft.plugin.cordovafacebook) .It needs Android facebook SDK,download from (http://developers.facebook.com/android/). Here is the share function form this plugin that covers your need(I suppose). function share() {
openFB.api({
method: 'POST',
path: '/me/feed',
params: {
message:"Facebook ApI test",
link: 'http://www.example.com/loc8',
name:'Facebook Api Test ',
//image that share in posted in user timeline
picture:'http://www.example.com/Test.png'
},
success: function() {
alert('Image Successfully shared in facebook');
},
error: errorHandler});
}
Also you can pass the image as argument like this
function share(image){
//do the facebook share stuff
}
Upvotes: 1