I’m having trouble posting a photo on Facebook using the social plugin. Twitter works fine. Any ideas if I’m doing something wrong or does the plugin currently not support this…?
Here’s a smallish test case (archive attached with main.lua, config.lua, and build.settings):
local widget = require “widget”
function Obj20EventHandler( event )
– for testing:
os.exit()
end
Obj20 = widget.newButton({
x = 284,
y = 320,
width = 14,
height = 14,
id = “Obj20”,
label = “X”,
font = “LucidaConsole”,
fontSize = 22,
strokeColor = { default = {1.0, 1.0, 1.0, 1.0}, over = {0.7, 0.7, 0.7, 1.0} },
onPress = Obj20EventHandler,
})
function Obj23EventHandler( event )
– save photo p to both directories:
display.save( p, { filename=“photo.jpg”, baseDir=system.TemporaryDirectory } )
display.save( p, { filename=“photo.jpg”, baseDir=system.DocumentsDirectory } )
– test image rects:
img = display.newImageRect(“photo.jpg”, system.TemporaryDirectory, 80, 80/p.ratio) – works
img.x = 75
img.y = 210
img2 = display.newImageRect(“photo.jpg”, system.DocumentsDirectory, 80, 80/p.ratio) – works
img2.x = 240
img2.y = 210
– test social plugin:
if event.target.id == “Obj23” then
serviceName = “facebook”
elseif event.target.id == “Obj27” then
serviceName = “twitter”
end
local isAvailable = native.canShowPopup( “social”, serviceName )
if ( isAvailable ) then
local listener = {}
function listener:popup( event )
Obj26.text =
“name: " … event.name…”\n"…
“type: " … event.type…”\n"…
“action: " … tostring( event.action )…”\n"…
"limitReached: " … tostring( event.limitReached )
end
native.showPopup( “social”,
{
service = serviceName,
message = “Hi there!”,
listener = listener,
image =
{
{ filename=“photo.jpg”, baseDir=system.TemporaryDirectory }, – twitter just does 1st img
--{ filename=“photo.jpg”, baseDir=system.DocumentsDirectory } – facebook does neither
},
url =
{
"http://lillipellilabs.com/queue-alert"
}
})
else
native.showAlert(
“Cannot send " … serviceName … " message.”,
“Please setup your " … serviceName … " account or check your network connection.”,
{ “OK” } )
end
end
Obj23 = widget.newButton({
x = 64,
y = 320,
width = 99,
height = 17,
id = “Obj23”,
label = “Facebook”,
font = “Helvetica Neue”,
fontSize = 22,
strokeColor = { default = {0.25, 0.54, 0.87, 1.0}, over = {0.17, 0.37, 0.61, 1.0} },
onPress = Obj23EventHandler,
})
Obj27 = widget.newButton({
x = 181,
y = 320,
width = 69,
height = 17,
id = “Obj27”,
label = “Twitter”,
font = “Helvetica Neue”,
fontSize = 22,
strokeColor = { default = {0.25, 0.54, 0.87, 1.0}, over = {0.17, 0.37, 0.61, 1.0} },
onPress = Obj23EventHandler,
})
Obj30_options = {
text = “img in tmp dir”,
x = 80,
y = 280,
width = 113,
height = 27,
align = “center”,
font = “HelveticaNeue”,
fontSize = 14,
align = “center”,
}
Obj30 = display.newText( Obj30_options )
Obj30.id = “Obj30”
Obj31_options = {
text = “img in doc dir”,
x = 240,
y = 280,
width = 113,
height = 27,
align = “center”,
font = “HelveticaNeue”,
fontSize = 14,
align = “center”,
}
Obj31 = display.newText( Obj31_options )
Obj31.id = “Obj31”
Obj26_options = {
text = “Results”,
x = 160,
y = 410,
width = 287,
height = 107,
align = “left”,
font = “HelveticaNeue”,
fontSize = 14,
align = “left”,
}
Obj26 = display.newText( Obj26_options )
Obj26.id = “Obj26”
– capture and display photo:
local function onComplete( e )
if e.completed then
p = e.target
p.ratio = p.width/p.height
p.x = 150
p.y = 75
p.width = 100
p.height = 100/p.ratio
end
end
if media.hasSource( media.Camera ) then
media.capturePhoto( { listener=onComplete } )
else
native.showAlert( “Corona”, “This device does not have a camera.”, { “OK” } )
end