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!
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
}
Related
I'm trying to "attach" a page to an uploaded video (via graph api) on Facebook, without any luck.
Creating a post (via /feed endpoint) and tagging on a place is working. Sharing a picture and tagging on a place is working. But not videos.
As I've seen in the official docummentation, the flow to "attach" a page is to use resumable uploads and then update the video via POST /<video_id> with { place: <page_id> }. But it's not working at all, besides the fact the API is returning { success: true }
I've also tried other alternatives:
Upload the video at once (not resumable).
Just specify the video url (not even getting the <video_id>).
Doing the POST /<video_id> update request via their Graph API explorer console.
I'm using version 2.8, the graph-video endpoint and have publish_actions permissions.
What could I be doing wrong? How do you do this?
Thanks.
I couldn't find any way to do this via the Graph Video api. The final solution for me was to create a feed post, via /me/feed specifying:
{
place: pageId,
coordinates: '{latitude,longitude}'
link: 'url'
}
being link an url pointing to a website that have the proper Open Graph attributes.
I can post a photo IF I had the time to get an app approved. I can share a link that pulls in a photo from THAT page. The goal is to post a link that goes to X, but the image is hosted somewhere else.
Is this possible?
Yes, it's possible by using the JavaScript SDK and the Share Dialog. For example, I can do the following, which shares a link but with a custom image, name and caption. It basically overwrites all the OG data on my page.
function fb_share() {
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
// do nothing
} );
}
$(document).ready(function(){
$('button.share-btn').on( 'click', fb_share );
});
You can do the same thing in PHP if you have the publish_actions permission approved by Facebook. Both would produce the following result:
Source
I post an action to a Facebook news feed from a website. I am getting a look that is not quite what I want to have:
I want it to be larger, like this one:
I am using JS SDK for posting, code comes from App, for testing-only in a dev-env it is currently following: (assuming user is authorized with correct permissions)
FB.api(
'me/aeegens:win',
'post',
{
thropy: "http://samples.ogp.me/444294502324595"
},
function(response) {
console.log(response);
}
};
I tried to look for solution in Facebook API documentation, but could not find it.
Answer is simple, one needs to have a bigger image.
Is it possible to upload image using the graph api or other method to facebook page ?
example appreciated
Of course it is possible. Look in Facebook.cpp for an example:
https://github.com/eamocanu/Facebook.Qt.APIs/blob/master/APIs/Facebook.cpp
method: uploadPhoto(..)
The entire API is hosted at https://github.com/eamocanu/Facebook.Qt.APIs
You can also download it from https://github.com/eamocanu/Facebook.Qt.APIs/downloads
I have a website where there is comments systems. I want to add a comment to facebook while adding a comment to my website.
If it is not possible to add to Facebook while adding to my site is it possible to show share to facebook button with each comments so that clicking on it will share that comment on facebook. May be possible with fb.in?
Not 100% sure, but it sounds like you have your own comment system on your web site and that you'd like to auto-publish to FB the comment that someone makes on your own site.
You'd need to implement the Facebook SDK on your web site:
Have your user authorize your site using 'FB.login' with 'publish_stream' permission (see docs).
In your comment system code, after your user has entered in their comment, you can make a separate call to the Graph API to publish to the user's feed. For example, if using the Facebook Javascript SDK:
Following is the code:
var body = myJustEnteredComment;
FB.api('/me/feed', 'post', { message: body }, function(response)
{
if (!response || response.error)
{
alert('Error!');
}
});