tag:blogger.com,1999:blog-865923359735383241.post3974785449965264903..comments2023-10-29T07:27:09.012-06:00Comments on Ccna final exam - java, php, javascript, ios, cshap all in one: Post message to facebook wall from android fb sdk always errorUnknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-865923359735383241.post-70347123648619104732012-06-05T21:58:24.206-06:002012-06-05T21:58:24.206-06:00I think the error message is quite clear... "...I think the error message is quite clear... "Key picture expected byte[] but value was a java.lang.String."<br /><br />The value for the key "picture" in your Bundle params should be a byte array, not a String.<br /><br />edit: Didn't read Cristian's answer. I'm pretty sure you should pass along the actual image data, not the filename in bytes. But I could be wrong.<br /><br />another edit: Yeah, so I'd downvote my own answer if I could, but it seems I didn't even read the question properly. The error happens not just for picture, so I have no idea what's wrong...Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-84971694010329312402012-06-05T21:58:23.279-06:002012-06-05T21:58:23.279-06:00The fix is:
if (parameters.get(key) instanceof by...The fix is:<br /><br />if (parameters.get(key) instanceof byte[]) {<br /><br /><br />instead of<br /><br />if (parameters.getByteArray(key) != null) {<br /><br /><br />on line 63 of Util.java.<br /><br />And <br /><br />if (params.get(key) instanceof byte[]) {<br /><br /><br />instead of <br /><br />if (params.getByteArray(key) != null) {<br /><br /><br />on line 155 of Util.java.<br /><br />For some strange reason, on Samsung Nexus S (perhaps other devices too) it returns a String, not a byte[].Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-82843240420557111152012-06-05T21:58:22.411-06:002012-06-05T21:58:22.411-06:00That's really weird... I have an app which use...That's really weird... I have an app which uses the same syntax but it works really well. I just check the source code of the FB SDK and it seems it has changed a lot... I found this on the SDK src:<br /><br /> for (String key : params.keySet()) {<br /> if (params.getByteArray(key) != null) {<br /> dataparams.putByteArray(key, params.getByteArray(key));<br /> }<br /> }<br /><br /><br />So, you try to do this:<br /><br />Bundle params = new Bundle();<br /><br />params.putByteArray("message", "Test".getBytes());<br />params.putByteArray("name", "American Virgin".getBytes());<br />params.putByteArray("link", "http://bit.ly/12345".getBytes());<br />params.putByteArray("description", "A Freshman College Girl on a scholarship from an ...".getBytes());<br />params.putByteArray("picture", "http://xxx/MOV1026.jpg".getBytes());<br /><br />mAsyncRunner.request("me/feed", params, "POST", new TestRequestListener());Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.com