Facebook integration

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Location: West-Cork, Ireland
Contact:

Facebook integration

Post by bertBUSIbr8 » Mon Apr 11, 2016 11:05 am

Hi,


I'm building a kiosk application for an exhibition that will allow visitors to send an electronic card via email and should share it on their Facebook account which will run on a Surface 3 running Windows10.

Therefor the app should be able to login to the user's Facebook account by providing their details [which will be deleted straight after posting]. I know about the facebooklib from Andre Garzia and happy to buy that but would like to clarify a few things before doing so as I'm not getting a clear view on this.

- Do I have to register the app on Facebook and get an appID.

- Does the app then need to be submitted to Facebook for approval?

- Should I register the app as the developer or should that be my client who will be running the app at the exhibition? Or does that not matter.

- Or is there a simpler way of posting an image onto a user's timeline bearing in mind it's not just one user using the app.



Many thanks,


Bert

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Facebook integration

Post by Mark » Sat Apr 16, 2016 8:25 pm

- Do I have to register the app on Facebook and get an appID.
Yes
- Does the app then need to be submitted to Facebook for approval?
Yes, but usually this isn't a big deal if you're just sharing something simple like a picture or a link.
- Should I register the app as the developer or should that be my client who will be running the app at the exhibition? Or does that not matter.
Probably, you should register the app, because that's easier for your client.
- Or is there a simpler way of posting an image onto a user's timeline bearing in mind it's not just one user using the app.
The only other way is to have a website open in an internet browser and ask the user to press a button on that website to share it. The website can be made in such a way that the desired picture is shared in the user's timeline. If you want to share something directly from within your app, you'll need a lib to authorize your app to post on the user's timeline.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Location: West-Cork, Ireland
Contact:

Re: Facebook integration

Post by bertBUSIbr8 » Fri Apr 22, 2016 11:03 am

Hi Mark,


Thanks for your reply.

Bit late in getting back about this here, been a busy time.

I'm going with the facebooklib from Andre Garzia for the Fb integration but one thing I don't seem to get on Facebook's developers application page is which type of app to choose. When I pick Windows it asks for a Windows store ID, which I won't have as it not a publicly available app.

If I pick web, as the login happens thorough the embedded browser it asks for a URL which I also won't have so not sure how to get past this hurdle?

Any help appreciated.



Bert

bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Location: West-Cork, Ireland
Contact:

Re: Facebook integration

Post by bertBUSIbr8 » Tue Apr 26, 2016 11:13 am

Hi,


Ok, so have it mostly working now. Picked web for app type on Facebook which seems to work fine, I'm able to post to my timeline.

The only thing I'm stuck with now is how to log out of Facebook so next time I come back, I'm not automatically logged in as me. Andre's FacebookLib has a logout function but that doesn't seem to do the trick or maybe I'm using wrongly.

If anyone has any experience with Andre Garzia's FacebookLib I'd appreciate the help!


Bert

bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Location: West-Cork, Ireland
Contact:

Re: Facebook integration

Post by bertBUSIbr8 » Tue May 03, 2016 12:09 pm

Hi,

Just wanted to bump this really as I'm stuck with the logout of Facebook.

If anyone knows of a way to clear the cache for the revBowser [where would the cache be located on Windows 10, I could delete it from there] that'd be great.

Or if someone has experience with the FacebookLib and managed to get the logout function to work. It doesn't log me out at the moment.


Thanks!


Bert

bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Location: West-Cork, Ireland
Contact:

Re: Facebook integration

Post by bertBUSIbr8 » Wed May 04, 2016 4:19 pm

Just in case someone else needs it, the cookies stored on Windows (10) from the revBrowser are in here:

C:\Users\USERNAME\AppData\Local\Microsoft\Windows\INetCookies

If I delete the cookie created by the Facebook login, I won't be auto-logged in next time and get a blank login again.


EDIT: I also had to delete the Facebook stack from memory to clear any variables and start afresh.


Bert

MWCoastMedia
Posts: 31
Joined: Fri Jan 16, 2015 5:31 pm

Re: Facebook integration

Post by MWCoastMedia » Wed May 18, 2016 8:41 pm

bertBUSIbr8 wrote:Or if someone has experience with the FacebookLib and managed to get the logout function to work. It doesn't log me out at the moment.
What I finally discovered at http://keganzo.blogspot.pt/2012/03/work ... t-url.html was that you can use a URL scheme to delete an access token using this format:

Code: Select all

https://www.facebook.com/logout.php?next=[YourAppURL]&access_token=[ValidAccessToken]
To get that to work, I replaced the fbLogout function that didn't work (sorry Andre) and replaced it with the following code that:
  • 1 - gets my saved token from a preference file
    2 - tell Livecode what the Site URL that was declared at dev.facebook.com for the Website platform of this App
    3 - launches a browser with the logout link
    4 - waits 2 seconds for Facebook to process the request (this was a guess, I assume there is some way to know when it has actually finished)
    5 - removes the browser used for logging out

Code: Select all

   set the defaultFolder to specialFolderPath("Documents")
   put line 3 of URL ("file:iotPrefs.txt") into tFBToken // unique user token saved earlier
   put "http://indianaontap.com" into tFBwebsite // this Site URL is unique for my Facebook app
   put "https://www.facebook.com/logout.php?next=" & tFBwebsite & "&access_token=" & tFBToken into tURL
   launchBrowser tURL
   wait 2 seconds // this was how long it was taking my browser to connect... no delay here and the token didn't get deleted
   _fbKillBrowser
Not the most elegant method, but is working for the time being.

bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Location: West-Cork, Ireland
Contact:

Re: Facebook integration

Post by bertBUSIbr8 » Wed May 18, 2016 8:45 pm

Oh! Very good.

Two solutions now. Will have to have a look at yours and give it a try. Probably more elegant than my slightly more brute force?


Bert

MWCoastMedia
Posts: 31
Joined: Fri Jan 16, 2015 5:31 pm

Re: Facebook integration

Post by MWCoastMedia » Thu May 19, 2016 9:29 pm

Correction: this needs to be a 1,2 punch in order to be effective.

In addition to the code above to clear the cookie from the browser, I also needed to delete the token from the app (I only deleted it from my preference file in the last example). Add the following code inside your fbLogout handler or wherever seems appropriate for your needs.

Code: Select all

put EMPTY into tFBToken
 fbSetAccessToken(tFBToken)
When I didn't add this code, the cookie was removed from the browser but the token still worked and was being used to authenticate....saved in the depths of the FacebookLib {sDataA["token"]["access_token"]).

Post Reply

Return to “Internet”