将保存屏幕发布到FB

时间:2015-06-13 12:43:15

标签: android ios facebook corona

我需要帮助来解决这个问题:我想在我的应用程序上发布一个保存屏幕(我使用display.save函数获得了保存屏幕)。一切都在Android上工作正常,而在我的iPad上它崩溃了!请在下面找到功能代码:

local function postonFB( event)
    display.save( tab3fields, { filename="ticket.jpg", baseDir=system.DocumentsDirectory, isFullResolution=true, backgroundColor={0, 0, 0, 0} } )

    local fbAppID = "4531113981XXXXX"  
    local function fbListener( event )
        if event.phase == "login" then
            local attachment = {
                message="I am a champion!",
                source= {baseDir=system.DocumentsDirectory, filename="ticket.jpg", type="image"}
            }

            facebook.request("me/photos", "POST", attachment)
            native.showAlert("Facebook", "Submitted!")
        end
    end

    -- photo uploading requires the "publish_actions" permission
    facebook.login( fbAppID, fbListener, { "publish_actions" } )
end

请帮忙,我疯了才能明白错误! 非常感谢。乌瓦尔多希

1 个答案:

答案 0 :(得分:0)

这是我的Facebook分享代码:

baseDir = system.DocumentsDirectory
display.save( group , "screenshot.png", system.DocumentsDirectory )

local facebook = require "facebook"
local fbAppID = "898209XXXXXXXXX" 

function onLoginSuccess()
    attachment = {
    message = "i got ".. score .. " blablabla",
    source = { baseDir=system.DocumentsDirectory, filename="screenshot.png", type="image" }
    }
    facebook.request( "me/photos", "POST", attachment )
end

function fbListener( event )
    if event.isError then
        native.showAlert( "ERROR", event.response, { "OK" } )
    else
        if event.type == "session" and event.phase == "login" then
            onLoginSuccess()
        elseif event.type == "request" then
            print("upload done")
        end
    end
end
facebook.login( fbAppID, fbListener, { "publish_stream", "publish_actions" } )

ps你在build.settings中有这个吗?

plugins =
{
    ["facebook"] =
    {
        publisherId = "com.coronalabs"
    },

},