【问题标题】:Error Unicode When Use RestFB使用 RestFB 时出现错误 Unicode
【发布时间】:2018-08-11 09:28:41
【问题描述】:

我正在编写 java spring + restfb 但我遇到了 unicode 值的问题

我的代码:

@SuppressWarnings({ "deprecation" })
     FacebookClient fbClient = new DefaultFacebookClient(ACCESS_TOKEN);
     Connection<JsonObject> results = 
             fbClient.fetchConnection("1173636692750000/feed", JsonObject.class,
             Parameter.with("fields", "full_picture,message"), 
             Parameter.with("limit", "5"));
List<Data> list = new ArrayList<>();
        for (JsonObject photo : results.getData()) {
            try {
                String photoUrl = photo.getString("full_picture");
                String message = photo.getString("message");
                list.add(new Data(photoUrl, message));
                System.out.println(message);
            } catch (Exception e) {
                System.out.println(".....");
                continue;
            }
        }

输出:

Hàng ba má thanh lý g?p?
Ai l??t bài ch?m em add ??
70kg ch?c em b? nh?t gr luôn roy ?
Ig : Ltasarah_1106
N?u em là thu?c phi?n, anh s? nghi?n hay cai??
Cmt ?i em addfr nah?!
Bây gi? tui có 2 cái l?ng nh? này th? các ông ch?n l?ng nào...
Ig: Zynnienguyen2704
Group có ai là Song Ng? sinh tháng 3 hông ?aaa ??

我的问题:如何解决这个错误?

【问题讨论】:

  • 你的java项目是utf-8的吗?

标签: java json spring-mvc restfb


【解决方案1】:

您可以尝试拨打String message = photo.get("message").asString()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-25
    • 1970-01-01
    • 2018-02-08
    • 1970-01-01
    • 1970-01-01
    • 2019-04-30
    • 2017-12-08
    • 2012-12-20
    相关资源
    最近更新 更多