Facebook Photo upload - blank image

I am trying to add an image on Facebook , but when i post it , i can see a BLANK image instead of
the actual image. I can see the discription, and if i upload three different size images i can see three different size Black images .

I am using JPG image , i followed blog :- http://blog.anscamobile.com/2011/12/uploading-photos-to-facebook-in-corona/comment-page-1/#comment-7258

I tried PNG images also but not working. And i am using Corona BUILD 767. I have a provisioning profile whose ID I am using.

here is my code :-
[lua]local facebook = require “facebook”
local bkgrnd = display.newImage(“globe_east.png”)

– You must use your own app id for this sample to work
local fbAppID = “285660044794607”

local function onLoginSuccess()
– Upload ‘iheartcorona.jpg’ to current user’s account
local attachment = {
message = “test user”,
source = { baseDir = system.DocumentsDirectory, filename=“inu.jpg”, type=“image” }
}
native.showAlert( "Log IN " , “Attachment is done Dipak” , { “OK” } )
– facebook.showDialog( {action=“stream.publish”} )
facebook.request( “me/photos”, “POST”, attachment )
native.showAlert( "Log In " , “Inside some logic” , { “OK” } )
end

– facebook listener
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( "Log IN " , “Login is done Vedangi” , { “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

function addImage()
local ImgGroup = display.newGroup()
local Img1 = display.newImage(“inu.jpg”)

ImgGroup:insert(Img1)

local baseDir = system.DocumentsDirectory
display.save( ImgGroup ,“inu.jpg”, baseDir )

– photo uploading requires the “publish_stream” permission
facebook.login( fbAppID, fbListener, { “publish_stream” } )
end
addImage()[/lua]

Please any one can help ?

Thanx Vedangi. [import]uid: 95790 topic_id: 23883 reply_id: 323883[/import]

Hey, Vedangi, you may want to start your code with < lua > and end with < /lua > (without the space after < and before > ) so that it’s easier to read.

Naomi [import]uid: 67217 topic_id: 23883 reply_id: 96332[/import]

Naomi

Thanx a ton :slight_smile: [import]uid: 95790 topic_id: 23883 reply_id: 96491[/import]

Naomi

Its Done :slight_smile: :smiley: The issue was i was using Documents Directory when i changed it to resource directory images were visible :slight_smile:

Finalllyyy

Thanx a lot for all ur support :slight_smile: [import]uid: 95790 topic_id: 23883 reply_id: 96493[/import]

Vedangi, so glad to hear you were able to sort this out.

Cheers,
Naomi [import]uid: 67217 topic_id: 23883 reply_id: 96500[/import]

I am having a similar problem. My (test) app calls display.save and writes this file to system.TemporaryDirectory. A native alert then triggers the upload to Facebook. The whole process seems to work (FB auth / upload) but the image is always black and seems to be 640x960px (iPad 1 & Galaxy Nexus) if that means anything.

I’ve stripped back my code and this is what I am testing with. Can anyone see what I am doing wrong? I’ve entered the correct details into my FB app page (it complains if anything is wrong)

[lua]display.setStatusBar(display.HiddenStatusBar)

local facebook = require “facebook”
local fbAppID = “455471331147847”

–system.TemporaryDirectory
local function onLoginSuccess()
local attachment = {
message = “Just a description of the photo.”,
source = {
baseDir=system.TemporaryDirectory,
filename=“testImage.jpg”,
type=“image”
}
}
facebook.request(“me/photos”, “POST”, attachment)
end

– facebook listener
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
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 background = display.newRect(0,0,320,480)
background:setFillColor(0,128,255)
local myObject1 = display.newRect( 50, 50, 100, 150 ) – Create a rectangle object
local myObject2 = display.newCircle( 100, 300, 50 ) – Create a circle object
local g = display.newGroup()
g:insert(background)
g:insert(myObject1)
g:insert(myObject2)

– photo uploading requires the “publish_stream” permission
display.save(g,“testImage.jpg”,system.TemporaryDirectory) --system.TemporaryDirectory

local function onTap(event)
facebook.login(fbAppID,fbListener,{“publish_stream”})
end

local function onTest(event)
local path = system.pathForFile( “testImage.jpg”, system.TemporaryDirectory )

– io.open opens a file at path. returns nil if no file found
local fh, reason = io.open( path, “r” )
local message

if fh then
message = “Opened OK”
else
message = "Failed to open: "…reason
end
native.showAlert(“Temp File”,message,{“OK”})
io.close( fh )
end

–background:addEventListener(“tap”,onTap)
native.showAlert(“Upload”,“Click OK to upload to Facebook”,{“OK”},onTap)[/lua]

Thanks [import]uid: 140429 topic_id: 23883 reply_id: 109489[/import]

I fixed my problem by giving the app more time to create the file. I take the screenshot before moving to this Facebook sharing code.

On a different note, I am now unable to send images to Facebook and via email. On iOS devices, this seems fine. I can’t see anything to do with Facebook, but when I try and email my image (screenshot), I get a message from my GMail app “Cannot display attachment”.

Is it a case that you can’t access the temporary file for some reason? [import]uid: 140429 topic_id: 23883 reply_id: 114206[/import]