Hi,
I added code to login to Facebook with only using the app id and did not do anything else on the app page in the developers page. I didn’t enter a class name or hash and when i try to login it lets me. But when i try to upload a photo it says it was a success but it’s not on my Facebook page. Is this still because I do not have anything else configured on the Facebook developers page? If so, why did it say I am logged in and the photo uploaded? This is for Android and below is my code. The app id is removed on this page.
UPDATE: Since I posted this I did the following. I commented out the line to upload the photo and instead had it just post a message. This works! The message appeared on my Facebook page. I then noticed I was calling the picture from the wrong directory and fixed it and tried again. It seemed longer before it said the image was uploaded but nothing appears on my page with the POST. Any suggestions why it works with the message but not with the attachment and the picture? Thanks!!
--facebook.request( "me/feed", "POST", attachment )
facebook.request( "me/feed", "POST", {message = "Hello Facebook"} )
Thanks
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
local facebook = require "facebook"
local appId = "removed"
local widget = require "widget"
local onComplete = function(event)
local photo = event.target
photo.isVisible = false
facebook.login( "removed", fbListener, { "publish\_stream" } )
end
local function fbListener( event )
if event.isError then
native.showAlert( "ERROR", event.response, { "OK" } )
else
if event.type == "session" and event.phase == "login" then
-- login was a success; call function
native.showAlert( "Success", "You are logged into Facebook!.", { "OK" } )
--onLoginSuccess()
elseif event.type == "request" then
-- this block is executed upon successful facebook.request() call
native.showAlert( "Success", "The photo has been uploaded.", { "OK" } )
end
end
end
local function onLoginSuccess()
-- Upload 'iheartcorona.jpg' to current user's account
local attachment = {
message = "Just a description of the photo.",
source = { baseDir=system.TemporaryDirectory, filename="CameraShot.jpg", type="image" }
}
facebook.request( "me/photos", "POST", attachment )
end
local onComplete = function(event)
if event.completed then
-- Camera shot was successfully taken.
-- Display at full resolution by passing in true.
-- display.newImage("CameraShot.jpg", system.TemporaryDirectory, true)
local attachment = {
message = "Just a description of the photo.",
source = { baseDir=system.TemporaryDirectory, filename="CameraShot.jpg", type="image" }
}
facebook.request( "me/photos", "POST", attachment )
else
-- User canceled out.
end
end
local listener = function( event )
if media.hasSource( media.Camera ) then
local filePath = { baseDir = system.TemporaryDirectory, filename = "CameraShot.jpg" }
media.show( media.Camera, onComplete, filePath )
else
native.showAlert("Corona", "Camera not found.")
end
return true
end
local onbtnLoginEvent = function (event )
if event.phase == "release" then
print( "You pressed and released a button!" )
--native.showAlert( "Success", "The button was pressed!.", { "OK" } )
facebook.login( appId, fbListener, { "publish\_stream" } )
end
end
local onbtnCameraEvent = function (event )
if event.phase == "release" then
local filePath = { baseDir = system.TemporaryDirectory, filename = "CameraShot.jpg" }
media.show( media.Camera, onComplete, filePath )
end
end
local btnLogin = widget.newButton{
id = "btn001",
left = 100,
top = 200,
label = "Facebook Login",
width = 170, height = 28,
cornerRadius = 8,
onEvent = onbtnLoginEvent
}
btnLogin.x = 100
btnLogin.y = 200
local btnCamera = widget.newButton{
id = "btn002",
left = 100,
top = 400,
label = "Take Picture",
width = 170, height = 28,
cornerRadius = 8,
onEvent = onbtnCameraEvent
}
btnCamera.x = 100
btnCamera.y = 400
[import]uid: 184193 topic_id: 32551 reply_id: 130452[/import]