创建新专辑时描述中的特殊字符

时间:2012-10-03 17:11:19

标签: javascript facebook-graph-api character-encoding facebook-javascript-sdk

我正在使用Facebook的Graph API和JavaScript SDK创建一个新专辑。使用描述(消息)和名称创建新专辑时,正在编码特殊字符。但是,当我尝试对字符进行编码时,一旦创建了相册,它们就不会被解码。还有其他人遇到过这个问题吗?

的JavaScript

/** Example One: Facebook encodes characters **/
var albumName = "Album Name";
var albumDesc = "Description with áéíóú";
FB.api("/me/albums", "post", {message:albumDesc, name:albumName}, function(res) {
     albumID = res.id;
     uploadPhotoToAlbum(albumID);
});

/** Example Two: Facebook does not decode characters **/
var albumName = "Album Name";
var albumDesc = "Description with %C3%A1%C3%A9%C3%AD%C3%B3%C3%BA";
FB.api("/me/albums", "post", {message:albumDesc, name:albumName}, function(res) {
     albumID = res.id;
     uploadPhotoToAlbum(albumID);
});

/** Example Three: Facebook does not decode characters **/
var albumName = "Album Name";
var albumDesc = "Description with áéíóú";
FB.api("/me/albums", "post", {message:albumDesc, name:albumName}, function(res) {
     albumID = res.id;
     uploadPhotoToAlbum(albumID);
});

1 个答案:

答案 0 :(得分:0)

对于可能遇到此问题的其他人,我发现这是由于文件编码造成的。将文件编码为UTF-8后,"示例一"按预期工作。