Hello everyone,
I developed an app and integrated Facebook plugin. Its working fine I am able to share things through my app. I have created few test users and mentioned their access token in my app so that I can use them for testing purpose. But my question is when my app go live what access token should I mention in my app? Do I have to use App Secret Code as my access token? If yes! Does it allow all the live users to share the stuff of my app on their wall?
local appId = "myAppID" local message = "" local access\_token = "????????" local fbCommand = ""
Please advise.
Thanks,
rob
October 2, 2017, 4:36pm
2
You get the token from a successful call to the .login() method. You should not be hard-coding tokens. You have no guarantee how long FB will keep one live.
Because of this, FB can only reasonably be tested on device.
Rob
rob:
You get the token from a successful call to the .login() method. You should not be hard-coding tokens. You have no guarantee how long FB will keep one live.
Because of this, FB can only reasonably be tested on device.
Rob
Thanks Rob,
I did it like this now.
Here is my lua code file
local facebook = require( "plugin.facebook.v4a" ) local json = require "json" local \_M = {} local appId = "myAppID" local message = "" local access\_token = "" local fbCommand = "" local LOGOUT = 1 local SHOW\_DIALOG = 2 local POST\_MSG = 3 local POST\_PHOTO = 4 local GET\_USER\_INFO = 5 local GET\_PLATFORM\_INFO = 6 function showPopup(popupTitle,popupMessage) native.showAlert( popupTitle, popupMessage, {"OK"} ) end function listener( event ) if ( "session" == event.type ) then if ( "login" ~= event.phase ) then showPopup("Facebook Share Failed!", "Please Try Again") return end access\_token = event.token if fbCommand == GET\_USER\_INFO then facebook.request("me") elseif fbCommand == POST\_MSG then facebook.request("me/feed", "POST", {message = message} ) end elseif ( "request" == event.type ) then local response = event.response if ( not event.isError ) then if fbCommand == GET\_USER\_INFO then response = json.decode( event.response ) elseif fbCommand == POST\_MSG then showPopup("Facebook Post Shared!", "You've Successfully Shared This Hadith On Your Timeline") end else showPopup("Facebook Share Failed!", "Please Try Again") end end end function \_M:postToWall(msg) message = msg fbCommand = POST\_MSG facebook.login( appId, listener, {"publish\_actions"} ) end return \_M
Is this OK?
And one more thing, once my app is live can users post on their timeline through my app?
Thanks,
rob
October 2, 2017, 8:58pm
4
My suggestion is to look at the Facebook sample app that ships with Corona in Corona/SampleCode/Networking/Facebook and study how that works.
Users of your app will be able to post to their own timeline as long as they have agreed to the “publish_actions” permission and you have successfully submitted your app to Facebook and go through their approval process. While testing they let you use “publish_actions”, but for live users to use it it will need to be approved.
Rob
Thanks Rob for all the help. I will consider corona’s facebook sample app.
My app is still in development process, once it’s done I will submit my app for approval on fb.
Thanks,
rob
October 2, 2017, 4:36pm
6
You get the token from a successful call to the .login() method. You should not be hard-coding tokens. You have no guarantee how long FB will keep one live.
Because of this, FB can only reasonably be tested on device.
Rob
rob:
You get the token from a successful call to the .login() method. You should not be hard-coding tokens. You have no guarantee how long FB will keep one live.
Because of this, FB can only reasonably be tested on device.
Rob
Thanks Rob,
I did it like this now.
Here is my lua code file
local facebook = require( "plugin.facebook.v4a" ) local json = require "json" local \_M = {} local appId = "myAppID" local message = "" local access\_token = "" local fbCommand = "" local LOGOUT = 1 local SHOW\_DIALOG = 2 local POST\_MSG = 3 local POST\_PHOTO = 4 local GET\_USER\_INFO = 5 local GET\_PLATFORM\_INFO = 6 function showPopup(popupTitle,popupMessage) native.showAlert( popupTitle, popupMessage, {"OK"} ) end function listener( event ) if ( "session" == event.type ) then if ( "login" ~= event.phase ) then showPopup("Facebook Share Failed!", "Please Try Again") return end access\_token = event.token if fbCommand == GET\_USER\_INFO then facebook.request("me") elseif fbCommand == POST\_MSG then facebook.request("me/feed", "POST", {message = message} ) end elseif ( "request" == event.type ) then local response = event.response if ( not event.isError ) then if fbCommand == GET\_USER\_INFO then response = json.decode( event.response ) elseif fbCommand == POST\_MSG then showPopup("Facebook Post Shared!", "You've Successfully Shared This Hadith On Your Timeline") end else showPopup("Facebook Share Failed!", "Please Try Again") end end end function \_M:postToWall(msg) message = msg fbCommand = POST\_MSG facebook.login( appId, listener, {"publish\_actions"} ) end return \_M
Is this OK?
And one more thing, once my app is live can users post on their timeline through my app?
Thanks,
rob
October 2, 2017, 8:58pm
8
My suggestion is to look at the Facebook sample app that ships with Corona in Corona/SampleCode/Networking/Facebook and study how that works.
Users of your app will be able to post to their own timeline as long as they have agreed to the “publish_actions” permission and you have successfully submitted your app to Facebook and go through their approval process. While testing they let you use “publish_actions”, but for live users to use it it will need to be approved.
Rob
Thanks Rob for all the help. I will consider corona’s facebook sample app.
My app is still in development process, once it’s done I will submit my app for approval on fb.
Thanks,