I want my app to get access to user profile and post a photo on her/his timeline. If I am doing this for android then am I requiring any hash key ? As when I build this code with a APP ID, I started getting good results, every thing fine but when I try to login any other profile, an error comes that say that “android_key _not_configured : The android key hash for this application is not configured.”
Here I am unable to get the fact that application works fine when I use my personal developer profile but fails and generates this error for other profiles. If I need a hash key then why this working fine for one case?
[lua]
local facebook = require “facebook”
local widget = require"widget"
local fbAppID = “my key” – my own generated key
local sessionComplete = function(event)
–removing the already existed image
if imageCaptured ~= nil then
imageCaptured.isVisible=false
end
imageCaptured = event.target
print( "Camera ", ( imageCaptured and “returned an image” ) or “session was cancelled” )
print( "event name: " … event.name )
print( "target: " … tostring( imageCaptured ) )
if imageCaptured then
imageCaptured:setReferencePoint( display.TopRightReferencePoint )
imageCaptured.width = display.contentWidth*0.5
imageCaptured.height = display.contentHeight*0.3
--displaying in the center
imageCaptured.xOrigin = display.contentWidth*0.75;imageCaptured.yOrigin = display.contentHeight*0.2
myimagename = “myimage.jpg”
local baseDir = system.DocumentsDirectory
display.save(imageCaptured , myimagename,baseDir )
end
end
–call when camera button is pressed
local function onCapturePress(event)
–text = “REPLACE PICTURE”
–print(“picture will only be taken when recording is on”)
if media.hasSource( media.Camera ) then
media.show( media.Camera, sessionComplete )
–print(“starting camera”)
else
native.showAlert(“Corona”, “Camera not found.”)
end
end
local function onLoginSuccess()
– Upload ‘iheartcorona.jpg’ to current user’s account
local attachment = {
message = “I want this to be printed on my facebook timeline.”,
source = { baseDir=system.DocumentsDirectory, filename=“myimage.jpg”, type=“image” }
}
facebook.request( “me/photos”, “POST”, attachment )
end
– facebook listener
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
onLoginSuccess()
elseif event.type == “request” then
– this block is executed upon successful facebook.request() call
native.showAlert( “Success”, “Your image has been posted.”, { “OK” } )
end
end
end
local function onSendPress(event)
– photo uploading requires the “publish_stream” permission
facebook.login( fbAppID, fbListener, { “publish_stream” } )
end
capture = widget.newButton{
style = “blackLarge”,
label = “CAPTURE” ,
onPress = onCapturePress
}
capture.x = display.contentWidth-(display.contentWidth*0.8)
capture.y = display.contentHeight-(display.contentHeight*0.1)
send = widget.newButton{
style = “blackLarge”,
label = “SEND” ,
onPress = onSendPress
}
send.x = display.contentWidth-(display.contentWidth*0.3)
send.y = display.contentHeight-(display.contentHeight*0.1)
[/lua]
I just using two buttons.
capture button is just capturing the image and send is posting to timeline.