Matt, I noticed what looks like some logic errors in your code. After logging in the first time with just basic permissions, you then logout and login again to request a publishing permission. That part is, in concept, OK, since it’s required by Facebook to have basic permissions before requesting an extended permission. But I think there are some problems with how you’ve implemented it:
-
After the first login succeeds, your code not only logs outs and attempts to login again, it also continues and attempts to post to Facebook. That will fail, since at the time, you don’t yet have the publishing permission
-
After the first login succeeds, and you logout and attempt to login again, the listener you pass to this second call to facebook.login() is facebookListener. However, that value will, at the time be nil, since it’s a reference to the function in which it’s occurring, and the function wasn’t predeclared. Since it’s nil, your listener won’t fire in response to the second login, and so the post will not be attempted. To call a function within itself, you have to predeclare it. As a simple example, compare the output of the following two snippets (the only difference is that, in the second one, myFunction is predeclared):
[lua]
local myFunction = function()
print(myFunction)
end
myFunction() – Will print nil
[/lua]
[lua]
local myFunction
myFunction = function()
print(myFunction)
end
myFunction() – Will print a reference to the function
[/lua]