Lua Lightroom-LrHttp不';我不会被处决

Lua Lightroom-LrHttp不';我不会被处决,lua,lightroom,Lua,Lightroom,目前,我正在为Lightroom制作一个插件,基本上需要登录用户并帮助他将图片上传到网站。不幸的是,我遇到了以下问题: LrHttp似乎不起作用。在“执行”之后,它会给我一个“nil”值 我知道通常请求需要一点时间来执行,我认为LrHttp已经在运行,而其余代码也在运行,这可能是个问题。因此,我寻找方法让LrHttp同步运行,但不幸的是没有成功 下面你们可以看到代码中似乎不起作用的部分-函数Picsize.login(电子邮件,密码) 在函数Picsize.login(电子邮件、密码)中,我

目前,我正在为Lightroom制作一个插件,基本上需要登录用户并帮助他将图片上传到网站。不幸的是,我遇到了以下问题:

  • LrHttp似乎不起作用。在“执行”之后,它会给我一个“nil”值
我知道通常请求需要一点时间来执行,我认为LrHttp已经在运行,而其余代码也在运行,这可能是个问题。因此,我寻找方法让LrHttp同步运行,但不幸的是没有成功

下面你们可以看到代码中似乎不起作用的部分-函数Picsize.login(电子邮件,密码)

在函数Picsize.login(电子邮件、密码)中,我们有:

如果有人帮助我或给我一些克服困难的建议,我会非常感激:)谢谢

if doingLogin then return end
doingLogin = true

LrFunctionContext.postAsyncTaskWithContext( 'PICSIZE login',

function( context )

    if not propertyTable.LR_editingExistingPublishConnection then
        notLoggedIn( propertyTable )
    end

    propertyTable.accountStatus = LOC "$$$/Picsize/AccountStatus/LoggingIn=Entrando..."
    propertyTable.loginButtonEnabled = false

    LrDialogs.attachErrorDialogToFunctionContext( context )

    context:addCleanupHandler( function()

        doingLogin = false

        if not storedCredentialsAreValid( propertyTable ) then
            notLoggedIn( propertyTable )
        end

    end )

    local email, password = PicsizeAPI.getCredentials()

    if authRequestDialogResult == 'cancel' then
        return
    end

    propertyTable.accountStatus = LOC "$$$/Picsize/AccountStatus/WaitingForPicsize=Aguardando uma resposta da plataforma PICSIZE..."


    -- this piece seems not to work
    local token = PicsizeAPI.login(email, password)

    if not token then
        return
    end

    local userData = PicsizeAPI.getUserData(token)

    if not userData then
        return
    end

    propertyTable.display_name = userData.display_name
    propertyTable.display_email = userData.display_email
    propertyTable.token = token

    PicsizeUser.updateUserStatusTextBindings( propertyTable )

end )
local request = getFormatedRequest(
    '/auth/login',
    { email = email, password = password },
    {{ field = 'Content-Type', value = 'application/json' }}
)

local response, headers = LrHttp.post(request.url, request.body, request.headers)

if response then
    return response.token
else
    return nil
end