【问题标题】:Titanium Android : Facebook dialog image URL not properly formattedTitanium Android:Facebook 对话框图像 URL 格式不正确
【发布时间】:2014-11-09 21:07:38
【问题描述】:

我使用 Titanium Appcelerator 开发了一个 Android 应用程序。我曾尝试通过 facebook 提要对话框发布文本和图像 .. 但是加载我的本地图片 URL 时出错..

var fileimg = Titanium.Filesystem.getFile(backupDir.nativePath, "myimg.jpg");

           var fb_data1 = {
                description : "Some good text",
                picture : fileimg.nativePath,
                link : "www.googlee.com",
            };

            facebook_qfav.dialog("feed", fb_data1, showRequestResult);

函数 showRequestResult(e) {

    var s = '';
    if (e.success) {
        s = "SUCCESS";
        if (e.result) {
            s += "; " + e.result;
        }
        if (e.data) {
            s += "; " + e.data;
        }
        if (!e.result && !e.data) {
            s = '"success",but no data from FB.I am guessing you cancelled the dialog.';
        }   
    } else if (e.cancelled) {
        s = "CANCELLED";
    } else {
        s = "FAILED ";
        if (e.error) {
            s += "; " + e.error;
            alert("facebook Share " + s);
        }
    }
}

错误“图片网址格式不正确”

文件路径如下: file:///storage/sdcard0/myimg.jpg

但是,如果我将远程 URL 传递给图片属性,则图像会显示在对话框中... 本地 URL 会怎样?

【问题讨论】:

    标签: android facebook titanium


    【解决方案1】:

    我认为唯一的问题是nativepath 中有大写字母 P。所以,它的:nativePath

    所以不是picture : fileimg.nativepath,应该是picture : fileimg.nativePath,

    Documentation.

    希望对你有帮助。

    【讨论】:

    • 它要求像这张图片的 URI 路径.. 我应该如何转换它
    • 你能举个例子吗?
    • 不,它不起作用..而不是本地路径,如果我通过远程图像位置它可以完美地工作..我不应该做什么。
    • 好吧,觉得你应该这样做:var f= Titanium.Filesystem.getFile(backupDir.nativePath, "myimg.jpg"); var blob = f.read(); var data = { message: 'This is a Picture', picture: blob };
    • 不,这也不起作用..我们不能直接将图像推送到这个属性..必须只传递位置..
    猜你喜欢
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-02
    • 2019-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多