Share a post on facebook from inside app

I would like to know how to share a post on facebook with info from inside the app we are building. We can send them directly to a facebook url, but we would like to enable the ability of sharing information for them automatically if they agree. Can anyone please help with this? We are using the rhostudio ide.

Joe Rider
You'll have to get the user's

You'll have to get the user's permission to access their Facebook account which will give you an access token to use Facebook's Graph API.  After you have the access token, a post can be sent to the user's profile with an HTTP POST to the Graph API.  The POST action could be done from within your application.  More information on how to setup your application to use the Facebook Graph API can be found at http://developers.facebook.com

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Michael Fisher
More specifically, if we can

More specifically, if we can't open the facebook app directly, then for some reason everytime we link a button to a facebook page that makes a post, it opens the facebook page in place of the app on iOS. and there is no way to get back to the app without shutting down the process and reopening the app. Any easy way to resolve this?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Joe Rider
Is there a reason the

Is there a reason the Facebook app needs to be opened?  If your goal is to make a post to a user's profile, you don't need to link to a Facebook page.  A better way to do this would be to trigger the HTTP POST with an AsyncHTTP request from a controller.  This way the content that is sent along with the HTTP request is posted to the user's profile without having to leave your app.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Michael Fisher
Okay. We would like to have

Okay. We would like to have the ability to open the facebook app if it is installed on their device. There are many apps out there that have the ability to share information on facebook, twitter, etc., and we would also like to do this. Do you have any specific examples i could look at for achieving this using your ide?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Divyansh Madan
So you want to open the

So you want to open the facebook app through your app?..Is that what you want to do or something else too?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Michael Fisher
Yes and yes. We would like to

Yes and yes. We would like to have the user give us access to post information to their facebook wall by: opening the app if installed, or if not installed to post via http. I know that we need their permission to do so, just trying to figure out how to accomplish this. Your help would be much appreciated. Thanks.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Divyansh Madan
If you can call the the

If you can call the the following method on the href of the button/listview or something else that you are using

def facebook

    System.open_url('facebook://facebook.com')//for ios use fb://facebook.com

    render :action => :index

  end

This would open the fb app in the device and if they dont have the app installed ,it will an alert sayin app not found.

If you want to open the http thing if the app isnt installed ,try checking the status of system.open_url...and if its not ok then change the link to https://m.facebook.com.see if this works

thanks

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Michael Fisher
Do i need to get the users

Do i need to get the users access token if the app isn't installed? And how should i go about making a post using the method you are proposing?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
To open the Facebook app no

To open the Facebook app no access token is required.  A token is required to make a post from your application.  Rhodes has a couple of built in methods to see if apps are installed on the device.

System.app_installed?(appname)  //Will tell you whether or not the app is installed.

System.run_app(appname, params)  //Will open the specified app with parameters  (appname is platform dependent in both methods)

More info on these methods at

http://docs.rhomobile.com/rhodes/device-caps#system-class

For the post method, I would read through the following documentation from Facebook and see if you can adapt it to use in a Rhodes app.

http://developers.facebook.com/docs/guides/web/

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Michael Fisher
I need to understand how to

I need to understand how to get this token applied to a global variable when it comes back from the redirect_uri I set up:

System.app_installed?(facebook)

      System.open_url('https://www.facebook.com/dialog/oauth?

        client_id=104348589714131

       &redirect_uri=http://127.0.0.1:#{current_port}

       &scope=publish_stream

       &response_type=token')

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Joe Rider
The access token is most

The access token is most likely present in the headers that come with the response to the redirect URI.  The redirect URI needs to be modified (http://127.0.0.1:#{current_port}/controller/action) to point to a controller action.  Inside of this action you can parse the headers from the response and get the access token.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Michael Fisher
One other item, how can i

One other item, how can i open this link:

https://www.facebook.com/dialog/feed?

app_id=#{app_id}&

link=" + $data['website'] + "&

picture="+ BctConfig.get('app_logo_url').value+ "&

name=Donation&caption=Blood%20Donation&description=#{address}%20#{date}%20#{time}&redirect_uri=https://staging.membersforlife.org/donorpro/response

in a separate window from my app, because i cannot get the 'rho_open_target="_blank"' to work or the System.open_url to work on this url either? Well, it works, but on iPhone it stays in the same window and i have to shut down the entire app and start over cause i have no back button like the droid does.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Divyansh Madan
the way i said would open the

the way i said would open the facebook app,and any further actions after that,you will have to use the token i guess,but for more information on that I would suggest you to visit the developer community of facebook.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments