Android Tutorial [TUTORIAL] Post to Facebook Wall via B4A app.

The attached project shows how to use the device's camera to snap a picture and upload it to your Facebook wall.

This sample is based on the code written by the one and only vb1992 found in THIS thread.

- Requirements:

1- Facebook account.
2- Facebook app.
3- Internet connection.

- How to create a Facebook app

In order to use this sample you MUST create a Facebook App first, to do that, go to: https://developers.facebook.com/apps/ (the system will prompt you to login if you are not, the user name and password required is your Facebook user name and password).

1- After you login you will see the Create new app window, then, enter a name and click on Continue (you can leave the rest of the fields blank, if you don't have a website then check the "free webhosting by Heroku" and follow the instructions).

2- Enter the Security check.

3- Fill the information on the App Details window, you need to enter:

  • Contact Email
  • Category
  • Select WEBSITE and enter your website (or the one provided by Heroku in case you don't have your own.)
  • Save changes

NOTES:

Take note of the App ID and App Secret you need those values to be added to the B4A project as well as the Site URL.

The first time you run the app you'll be prompted to login to Facebook, there's no log off option, the workaround is to CLEAR DATA & CLEAR CACHE, I need to investigate how to do that by code.

There are a few notes in the B4A project, just follow those simple instructions and you are done.

Enjoy!!
 

Attachments

  • FacebookCamSample.zip
    9.8 KB · Views: 2,301

derez

Expert
Licensed User
Longtime User
I guess because it is hosted by Heroku, there is no place to put it.
 

derez

Expert
Licensed User
Longtime User
I opened a tab and saw this, is the fact that there is nothing there may be the reason ?
 

Attachments

  • problem3.png
    problem3.png
    27.3 KB · Views: 386

derez

Expert
Licensed User
Longtime User
So it is OK the way it is. If I find a site (other than Heroku) to be the mediator, what do I need to put there - a php or similar application ?
Do you have an example of such ? I need the usual - to post results of a game...

Edit: I tried to create a new app in FB without asking for a host, but I don't get the category and site url like in your example...

edit: I have found the site URL in this tab "Website with Facebook Login" but no category

Edit: I put the same address of heroku, now I get a simple error message saying " An error occurred, try again later"

EDIT: Changed the site address to be with www and now it ask to login..... AND it works !
Thank you Njdude !
 

Attachments

  • problemsolved.png
    problemsolved.png
    9.6 KB · Views: 400
Last edited:

derez

Expert
Licensed User
Longtime User
Now to the question of deleting the cache for a new login process, by code.
I listed the files in File.DirInternalCache and got these:

webviewCacheChromiumStaging
webviewCacheChromium

Deleting them left the second file and didn't do the required effect.

Does anybody know how it can be done ?
 

NFOBoy

Active Member
Licensed User
Longtime User
WebView not staying displayed with code as shown

So, I have the app created, and have the id/secret/redirect setup,
but I am not getting expected results when I run through.


Had to change this line from

B4X:
If Url.StartsWith("http://m.facebook.com/login.php") Then

to

B4X:
If Url.StartsWith("https://m.facebook.com/dialog")

to get the webview to stay visible


And the url returned when it is all done looks like this (modified to keep this from actually being used by someone to post on my FB account!)

B4X:
http://iii.m.webs.com/site/mobile?dm_path=%2Findex.htm&fw_sig_tier=0&fw_sig_url=http://iii.love.com/&fw_sig_api_key=522b0eedffc1374949085nf3a1&fw_sig_premium=0&fw_sig_social=0&fw_sig_permission_level=0&fw_sig_access_token=e37c25c468ebaafadfdfoj848e524fc7&fw_sig_time=1370170181271&fw_sig_is_admin=0&fw_sig_permissions=none&fw_sig_session_key=517c5f991daf4e64adc2c0625dfjojeiojer2c89fa8607a9888f6f0f2be21-93242559&fw_sig_site=93242559&fw_sig=fbd96cf2d59doijdfdfc0139a5295216&fb_sig_network=fw#3132

Did something big change? Or did I mess up the application process?

I put in my site url in the Website with Facebook Login, and then put that in the app domains on the basic info page... and that was about it.

????

Ross
 

luke2012

Well-Known Member
Licensed User
Longtime User
Post in specific FB Page

It's possible to customize this sample in order to upload a post with Text and Image to a specific Facebook page?
 

MaxApps

Active Member
Licensed User
Longtime User
Is it possible to upload text together with the picture and have a link in it as well?
I would like my user to be able to post "Just made a new highscore in appname" and if other people click on it, it links to Google Play.
 

oyvinrog

Member
Licensed User
Longtime User
This example did not work for me. I tried to change all the "http://" references into "https://". Then it worked.
 

pietervdb

Member
Licensed User
Longtime User
Does this example still work? I had it working in the past but the send button seems not responding (no code change in my app).. Anyone tested this?
 

figorra

Member
Licensed User
Longtime User
This app not work for me, because don't do nothing when I push send button..... I create a facebook developer account, web type and the secrets and test app are done........

What's the problem?
 

stp

Member
Licensed User
Longtime User
Example does not work...
Picture taken and after send nothing happens !!!
 

stp

Member
Licensed User
Longtime User
Yes i know they plan to update to 2.1
Is here in the forum any working example where i can login an post to my fb profile ?
 
Top