如何在Titanium的Facebook模块对话框中添加图片?在钛的例子,在对话框中的图片属性是一个图片从一个网站的链接:Facebook模块对话框错误图片格式不正确
var data =
{
link : "http://www.appcelerator.com",
name : "Appcelerator Titanium Mobile",
message : "Checkout this cool open source project for creating mobile apps",
caption : "Appcelerator Titanium Mobile",
picture : "http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png",
description : "You've got the ideas, now you've got the power. Titanium translates " +
"your hard won web skills into native applications..."
};
fb.dialog("feed", data, function(e)
{
if(e.success && e.result)
{
alert("Success! New Post ID: " + e.result);
}
else
{
if(e.error)
{
alert(e.error);
}
else
{
alert("User canceled dialog.");
}
}
});
但是,如果你想使用的图片是本地而不是通过一个这样的网站的链接是什么?
var data =
{
link: "http://play.google.com/",
name: "Android app's name",
picture: "file:///data/data/com.appid/app_appdata/directory/name-of-image.jpg"
};
我得到图片属性格式错误,如果我使用上面的代码。见视觉参考这一形象:http://postimg.org/image/wjefdlalb/
我使用文件系统这样的尝试:
function getFile()
{
var imageFileToPost;
var imageFile = Ti.Filesystem.getFile("file:///data/data/com.appid/app_appdata/directory/name-of-image.jpg");
if (imageFile.exists())
{
console.log("exists");
imageFileToPost = imageFile.read();
}
return imageFileToPost;
}
var data =
{
link: "http://play.google.com/",
name: "Android app's name",
picture: getFile()
};
和邮政是成功的,没有错误,但图像没有公布在Facebook上。
注意:我会使用图表,但我需要使用像'publish_actions'这样的权限,这意味着我必须让Facebook查看应用程序,但即使用户可以编辑消息,也不喜欢预填消息。那么这真的只是Facebook模块对话框的一个格式问题,或者它只需要一张图片的URL?如果这是一个格式问题,任何人都可以告诉我如何正确格式化,因为我真的需要使用本地图片而不是网站图片?
你可能要检查[此帖](http://www.titaniumtutorial.com/2012/03/create-album-and-post-photos-in.html) – turtle 2014-11-25 05:26:11
嗨龟,感谢您的时间,但我宁愿不使用图。我使用了图表并使用了publish_actions,但被Facebook拒绝了,因为我已经预先填充了用户可以编辑的消息。 Facebook只是不喜欢预先填写的消息,对话让我可以预先填充链接和图片等数据,而无需询问Facebook的权限。 – junerockwell 2014-12-01 19:17:48