facebook android sdk - can't decode profile picture from json response - android

I was playing with facebook android sdk. Till yesterday their sample Hackbook example code was working. But today it is not working any more. I looked into the json response and it seems like facebook changed their json response format.
This is the response for request field of "name, picture":
{"name":"Mohammad Haque","id":"xxxxxxxx","picture":{"data":
{"url":"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-ash3\/xxxx.jpg","is_silhouette":false}}}
It looks like profile url now wrapped inside another parent item. Has anyone faced this problem? I could not find any relevant information on facebook.
Thanks

It is the Facebook updates http://developers.facebook.com/roadmap/
According to Facebook documentation (https://developers.facebook.com/docs/reference/api/user/) - picture returns string; If the "October 2012 Breaking Changes" migration setting is enabled for your app, this field will be an object with the url and is_silhouette fields; is_silhouette is true if the user has not uploaded a profile picture
I retrieved picture url by this query:
https://graph.facebook.com/me/picture?type=large

JSONObject jb=Util.parseJson(query);
JSONArray ja=jb.optJSONArray("picture")
JSONArray v=ja.optJSONArray("data")
JSONObject j=v.optJSONObject(0);
j.get("name").toString();
j.get("url").toString();

Just parse the JSON appropiately with the changes and it should work.

Related

what is this response format image

i am trying to create an app which removes the image background, the send the image through api key and server sends the response, here i get response but i coulnt understand the response image format. PLEASE senior developer and programmers help me.
sample response code : : ‰PNG
������IHDR����˜����������,ƒ7ª����
{{{;Ž}ƒ#âtp¶8_<Nˆ+ÄUàZp'pWp¸¼ÞïŒÅóðËñeøF|?ŽŸ!(Œ ®„HBa-¡’ÐF8K¸KxA$õˆNÄp¢€¸†XI<D<O%¾%QHf$6)$!m!í'"Ý"½ “ÉFdr<YLÞBn&Ÿ!ß'¿Q X(ðV+Ô(t\Qx¦ˆW4TôT\¬˜¯X¡xDqHñ©^ÉH‰-ÄQZ¥T£tTé†Ò´2UÙF9T9Cy³r‹òåG,ňâCáQŠ(û(g(cT„ªOeS¹ÔuÔFêYê8C3¦ÐRi¥´ohƒ´)ŠŠJ´JžJÊq)¡Ñèéô2úaúuú;U-UOU¾ê&Õ6Õ+ª¯Õæ¨y¨ñÕJÔÚÕFÔÞ©3Ô}ÔÓÔ·©w©ßÓ#i˜i„käjìÑ8«ñtmŽË9‡çÜÖ„5Í4#4WhîÓÐœÖÒÖòÓÊÒªÒ:£õT›®í¡ª½Cû„ö¤UÇMG ³Cç¤Îc†
5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶t¥çÊúUЪ¥«zWë¯.Z=¾Æo͵„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K-K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{-fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~éˆ}ÍŽÍÍ-š-e¬p«¤uòÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s-/¼oðlÐÙóç|Ïé÷ì?yÞõü±ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú¬ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñOŸ~÷„óû¤Ì\9������ pHYs����������šœ������IDATx^ìýœ¤éUÞŸÊ
Well, this is PNG as it starts with ‰PNG..

Jumblr API gives bad request while posting image to Tumblr

What I have
I have an image File object trying to post to Tumblr using Jumblr API
My problem
When I try to post the image I get com.tumblr.jumblr.exceptions.JumblrException: Bad Request Response code :400
My code
client = new JumblrClient(CONSUMER_KEY,SECRET_KEY);
client.setToken(TOKEN, TOKEN_SECRET);
User user=client.user();
userName=user.getName();
PhotoPost photoPost=client.newPost(client.user().getBlogs().get(0).getName(),PhotoPost.class);
photoPost.setCaption("My Tumblr post");
photoPost.setPhoto(new Photo(Methods.FILE_IMAGE));
photoPost.save();
I've encountered the same issue using Jumblr.
Instead of this method (does it somehow trigger Android gallery? Couldn't find any javadoc for Methods.FILE_IMAGE)
photoPost.setPhoto(new Photo(Methods.FILE_IMAGE));
I suggest you to try any flavor of
photoPost.setData(new File(fileName)); //if it's possible on Android
And please try it with different files: Tumblr has not only file-size limitations, but also some weird check for file being valid. ~3% of gif files I upload throw Bad Request Response code :400. Those files are not exceeding GIF size limit and they're displayed fine on my machine, but Tumblr, for some reason rejects them, so please try post.setData and try it with some bulletproof-valid file, because from the rest of your code - it definitely looks like you're doing it right
I had a similar problem posting a video & audio. However, posting an Image worked like a charm..
JumblrClient client = new JumblrClient(
CONSUMER_KEY,
SECRET_KEY
);
client.setToken(
TOKEN,
TOKEN_SECRET
);
PhotoPost post = client.newPost(strBlogName, PhotoPost.class);
post.setCaption("This is my caption");
post.setData(new File(fileUri.getPath()));
post.save(); //Initiates upload of image file

How to check if an image/image link is present in text in android

I am creating an android application. I am getting the response from server in json format. I ma parsing the json response. When I get the content it may contain image or video link. How can I check whether image or video link is present in the content and download the corresponding image or video and display it in my application. I am aware f downloading images and displaying them, but I am not aware of how to check for the link.
My response is in the following format:
<p class='para-inside-post'> cool panda <a class='handler_name' href='/#12'>#12</a> </p><img class=\"post-img-tag\" postcreatorid=\"56332edfad441746cbd15000\" src=\"https://image.jpg\" height=\"430px\" width=\"430px\">"
I am parsing the text as shown below:
postContentSplit = Html.fromHtml(content).toString();
Similarly, how can I do the same for images and videos?
All suggestions are welcome. Please help me come out of this issue.
Use Patterns in order to check url validity
Patterns.WEB_URL.matcher(potentialUrl).matches()
It will return True if URL is valid and false if URL is invalid.

Unable to fetch GPlus profile pic. Is the Google Plus Image fetch URL updated?

It's weird, but till yesterday i was able to get the gplus user's image in my app but today it's just not coming. Nothing simply blank. And just appears at some time..
I have been using the urls specified in Getting Google+ profile picture url with user_id but these all seem invalid and gives 404 Error.
https://plus.google.com/s2/photos/profile/116018066779980863044?sz=100
If anybody could help me out why this weird behaviour. The Profile pic appears seldom. But mostly it's blank.
The image URL you were using was never a public API and so there was no guarantee it would continue to work. The recommended practice going forward is to use the people.get API method to get the profile => image => url value instead. That URL could stop working if the user changes their avatar so you might want to fetch the actual image and cache it on your own servers.
I think the Image url has been updated.
Inorder to get that, we can use the PlusClient objects methods:
imageURL = mPlusClient.getCurrentPerson().getImage().getUrl()
{Returns a String - Image Url as String}
imageURL = mPlusClient.getCurrentPerson().getImage()
{Returns an instance of Image object}

Android - Facebook wall post parameters

I am posting to a user's wall on Facebook. How can I add a link to the post next to the like and comment links, as seen on the illustration below. What is the parameter name I should include in my request?
This is what I eventually did:
The link besides the like and comment is called "actions". To add it, you need to create an array of actions (actually, as I understand only one action is supported). For example:
JSONObject actions = new JSONObject();
actions.put("name","Get Your App");
actions.put("link", "Your app URL");
parameters.putString("actions", actions.toString());
Here is list of all Post Fields.
link | The link attached to this post | Requires access_token | string containing the URL

Categories

Resources