Announcement Announcement Module
Collapse
No announcement yet.
Encoding problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Encoding problem

    Hi guys! I'm facing an encoding issue on my Android project while posting an image to the user's Facebook profile.
    The image's caption is written in brazilian portuguese, so when I use characters like é, ã and á I get invalid symbols when I check the image's caption on Facebook.

    I'm using the following libs:
    • spring-android-auth-1.0.0.RC1.jar
    • spring-android-core-1.0.0.RC1.jar
    • spring-android-rest-template-1.0.0.RC1.jar
    • spring-security-crypto-3.1.0.RELEASE.jar
    • spring-social-core-1.0.2.RELEASE.jar
    • spring-social-facebook-1.0.1.RELEASE.jar

    Can anyone help me out?
    Thanks!

  • #2
    Just trying to narrow the problem down a bit...is there any chance this has nothing to do with Android? Can you recreate the problem in a standard main() method?

    I ask because if it's truly a problem in Android, then I don't mind setting up the scenario to run it in Android and see what happens. But if it's not Android-specific, it'll be a lot easier to debug and test in a main() method or JUnit test. And if you manage to recreate it outside of Android, could you share that code here so I know that I'm debugging the same thing you're trying to do?

    Comment


    • #3
      Ok, I'm on it!

      Comment


      • #4
        Hi habuma,

        I could reproduce the problem in a main() method outside my Android project. It seems that when posting feed contents there is no encoding problems, but when posting photos there is. Please have a look at the attached image below.

        I can send you the code I wrote, but as it contains sensitive data (access token, app secret) I'll do it privately, ok?

        Thanks in advance.

        Attachment
        Attached Files

        Comment


        • #5
          If you can, just post the code here, but put placeholders for the token and secret (e.g., ACCESS_TOKEN and APP_SECRET). I'll take the code and plug in my own token/secret to test with.

          Comment


          • #6
            Ok, here is the code:

            package spring.social;

            import org.springframework.core.io.ClassPathResource;
            import org.springframework.core.io.Resource;
            import org.springframework.social.connect.Connection;
            import org.springframework.social.connect.ConnectionData;
            import org.springframework.social.facebook.api.Facebook;
            import org.springframework.social.facebook.connect.Facebo okConnectionFactory;

            public class App {

            private String clientId = "";
            private String clientSecret = "";
            private String accessToken = "";
            private String displayName = "";
            private long expireTime = 0L;
            private String imageUrl = "";
            private String profileUrl = "";
            private String providerId = "facebook";
            private String providerUserId = "";

            public App() {
            FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory(
            clientId, clientSecret);
            ConnectionData connectionData = new ConnectionData(providerId,
            providerUserId, displayName, profileUrl, imageUrl, accessToken,
            null, null, expireTime);
            Connection<Facebook> connection = connectionFactory
            .createConnection(connectionData);
            Facebook api = connection.getApi();
            Resource photo = new ClassPathResource("nautilus.jpg");
            api.mediaOperations().postPhoto(photo, "Meu café da manhã"); // has encoding problem
            api.feedOperations().post(providerUserId, "Meu café da manhã"); // no encoding problem
            }

            public static void main(String[] args) {
            new App();
            }

            }


            JARs in my classpath:
            spring-social-core-1.1.0.BUILD-SNAPSHOT.jar
            spring-web-3.1.0.RELEASE.jar
            aopalliance-1.0.jar
            spring-beans-3.1.0.RELEASE.jar
            spring-context-3.1.0.RELEASE.jar
            spring-aop-3.1.0.RELEASE.jar
            spring-expression-3.1.0.RELEASE.jar
            spring-asm-3.1.0.RELEASE.jar
            spring-core-3.1.0.RELEASE.jar
            commons-logging-1.1.1.jar
            spring-social-facebook-1.1.0.BUILD-SNAPSHOT.jar
            jackson-mapper-asl-1.9.3.jar
            jackson-core-asl-1.9.3.jar
            spring-security-crypto-3.1.0.RELEASE.jar

            Comment


            • #7
              Thanks...I'll try it out and let you know what I find...stay tuned.

              Comment


              • #8
                Hi habuma,
                did you happen to solve this issue? Looks exactly like one i'm dealing with.
                I'm using 1.0.2.RELEASE spring social and 1.0.0.RELEASE spring for android

                Comment


                • #9
                  I'm also having exactly the same issue; I'm using spring-social-core-1.0.2.RELEASE and spring-3.1.1-RELEASE for JRE.

                  Didn't anyone else stumble into this same problem?
                  Did any of the developers even take a look at the problem?

                  Comment


                  • #10
                    Yes, it was looked at and several encoding problems have been fixed in recent releases. I can't put my finger on *when* this was fixed (at least not without digging deeper in Git logs), but I just tried it with 1.1.0.M2 and it worked fine. If you're still having trouble, please open an issue at https://jira.springsource.org/browse/SOCIALFB.

                    Comment


                    • #11
                      Okay, thank you; I'll try 1.1.0.M2, though I may only be able to make the test next week.
                      Last edited by haroldoats; Feb 19th, 2013, 09:45 AM.

                      Comment


                      • #12
                        That'd be great. Even though I tried it this morning, I just noticed a few places where there still may be a problem and I may need to do additional testing. If you can bounce your own tests against it and provide feedback, that'd be tremendously helpful.

                        Comment


                        • #13
                          FWIW, I just tested this with the following snippet of code (with Spring Social 1.1.0.M2):

                          Code:
                          FileSystemResource photo = new FileSystemResource("/Users/habuma/Pictures/HauntedMansion.jpg");
                          fb.mediaOperations().postPhoto(photo, "Meu café da manhã");
                          And, as you can see from the attached screen shot, it worked as I'd have expected. Therefore, I consider this issue closed. But if you find otherwise, please consider opening a bug issue at https://jira.springsource.org/browse/SOCIALFB.

                          Comment


                          • #14
                            I've just tested version 1.1.0.M2 this morning. The problem seems to have been fixed, thanks.

                            Comment

                            Working...
                            X