Obtaining facebook cover photos - android

How I can get the cover photo of the albums of a user in my application?
Currently, I have a json like this:
"id": "00000",
"albums": {
"data": [
{
"id": "428076573767",
"from": {
"name": "Benjamin",
"id": "00000"
},
"name": "Profile Pictures",
"link": "https://www.facebook.com/album.php?fbid=00000&id=00000&aid=00000",
"cover_photo": "10151465301937683",
"privacy": "everyone",
"count": 57,
"type": "profile",
"created_time": "2010-09-05T08:42:19+0000",
"updated_time": "2013-04-27T23:53:11+0000",
"can_upload": false
},
}
How I can get the cover_photo by URL?

You can get cover photo by adding this into URL. No need to extract cover_photo from Json .
album['id']?>/picture?access_token=12345
// where album is JSON array and access_token is random here..
Try this. It will work.

Related

Dynamic JSON parsing

I am a newbie to android. I am stuck at JSON parsing.
Following is my JSON, in this, the type of menu categories will be dynamic, and I want to arrange this JSON in sectioned recycler view.
Please help me out.
This is my JSON
{
"menu_items": {
"Plat": [{
"menu_name": "jambon à l'os",
"menu_cost": "18.00",
"menu_count": "1",
"category": "Plat",
"menu_tax": "5.50",
"code": "€"
},
{
"menu_name": "tacos",
"menu_cost": "6.00",
"menu_count": "1",
"category": "Plat",
"menu_tax": "5.50",
"code": "€"
}
],
"Entrée": [{
"menu_name": "avocat",
"menu_cost": "7.50",
"menu_count": "1",
"category": "Entrée",
"menu_tax": "5.50",
"code": "€"
}]
},
"order_data": {
"order_id": "278",
"order_number": "REF-5d5e6b86",
"created_at": "1566468998",
"instructions": "",
"fullname": "Rohan Chitnis",
"phonenumber": "7610771871",
"useraddress": "Brest, France",
"image_path": "https://restau-at-home.bzh/uploads/attachments/Jellyfish_2019_08_21_10_49_21.jpg",
"wp": "pune",
"code": "€",
"promocode": null,
"promo_value": null,
"promo_type": null
},
"order_details": {
"total_items": "3",
"order_total": "31.50"
},
"promo_applied": "0",
"error": {
"code": "13",
"status": "200",
"message": "Ok"
}
}
Check this out. Create a generic response class. Extend your classes from that class. To do this properly you can look at Java Generics and Inheritance topics if you are using Java. And then search about Sectioned RecyclerView in Android. Here is a library for this.

How to get Image URL based on name

My JSON contains only name of the food categories, Looks like below
[
{
"cu_id": "2",
"cuisine_type": "American"
},
{
"cu_id": "24",
"cuisine_type": "Sandwich"
},
{
"cu_id": "17",
"cuisine_type": "Seafood"
},
{
"cu_id": "29",
"cuisine_type": "Sports Bar"
},
{
"cu_id": "5",
"cuisine_type": "Steak"
},
{
"cu_id": "20",
"cuisine_type": "Sushi"
}
]
I want to get default image automatically from Internet by searching 'cuisine_type', How to do that?
You can use pixabay api it's a free RESTful api for searching and retrieving free images and videos released on Pixabay under Creative Commons CC0.
Sending a GET request like this :
https://pixabay.com/api/?key={ KEY }&q=query&image_type=photo
where :
Key : the api key you get after creating an account
q : the queried object you need to look for
image_type : what kind of data you need (picture, video)
returned data will be something like this :
{
"total": 4692,
"totalHits": 500,
"hits": [
{
"id": 195893,
"pageURL": "https://pixabay.com/en/blossom-bloom-flower-yellow-close-195893/",
"type": "photo",
"tags": "blossom, bloom, flower",
"previewURL": "https://static.pixabay.com/photo/2013/10/15/09/12/flower-195893_150.jpg"
"previewWidth": 150,
"previewHeight": 84,
"webformatURL": "https://pixabay.com/get/35bbf209db8dc9f2fa36746403097ae226b796b9e13e39d2_640.jpg",
"webformatWidth": 640,
"webformatHeight": 360,
"imageWidth": 4000,
"imageHeight": 2250,
"imageSize": 4731420,
"views": 7671,
"downloads": 6439,
"favorites": 1,
"likes": 5,
"comments": 2,
"user_id": 48777,
"user": "Josch13",
"userImageURL": "https://static.pixabay.com/user/2013/11/05/02-10-23-764_250x250.jpg",
},
{
"id": 14724,
...
},
...
]
}
for more detail visit this link

Which Tag in Json file to fetch the YouTube Video on Android application on ListView Item?

Here is my json file i use thumbnail on listview but there no such tag that fetch videos . Define it which tag i use ?
That perfectly add thumbnail or other things
Below is my preview of Listview items
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/uvcwjZ_9_NYCLF7JAzfY5FiuzuQ\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1998,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#playlistItem",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/dCBViPWfe-MGrqHIcuMZ55HcLJ0\"",
"id": "VVVHaENWR1owWlNwZTVoSkhXeWlMd0hBLlZHRHFaakFMSF9N",
"snippet": {
"publishedAt": "2017-01-26T08:58:26.000Z",
"channelId": "UCGhCVGZ0ZSpe5hJHWyiLwHA",
"title": "Top 10 - Scariest scenes in Resident evil 7",
"description": "Resident Evil 7 brings the series back to its roots while mak Epidemic Sound.\nhttp://www.epidemicsound.com/youtube-creator-subscription/",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/VGDqZjALH_M/default.jpg",
"width": 120,
"height": 90
},
},
"channelTitle": "ZoominGames",
"playlistId": "UUGhCVGZ0ZSpe5hJHWyiLwHA",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "VGDqZjALH_M"
}
}
},
Well, it is true that you cannot find any url in the json output. The only thing that you can get from here is the videoId.
You can use this videoId as part of this https://www.youtube.com/watch?v="insert_videoId" to get a video link.
So in your case, this is the link https://www.youtube.com/watch?v=VGDqZjALH_M

How to get Array of array(result values Specially CommentUser[] and BarLike[]) from json string using jackson in Android?

I want to get the value of CommentUser[] and BarLike[] but not able to fetch that array of array from this JSON string .
Please refer this link for View my parsing code :
https://www.dropbox.com/s/rws784060dblbq4/Untitled.png?dl=0
{
"success": "1",
"msg": "Closures found.",
"details": {
},
"result": [{
"name": "Miles Davis",
"birthDate": -1376027600000,
"CommentUser": [{
"like": 0,
"unlike": 1
}],
"BarLike": [{
"like": 0,
"unlike": 1
}]
}]
}

Parse JSON with facebook sdk

I was wondering how to get the value of "name" for the following json text with facebook sdk. Assuming I have already got the access token. Any thoughts? Many thanks!
enter code here
{
"id": "100005065353669",
"music": {
"data": [
{
"category": "Musician/band",
"name": "Eason Chan",
"id": "105468519487919",
"created_time": "2013-06-05T20:33:26+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/100005065353669/musiclimit=5000&offset=5000&__after_id=105468519487919"
}
}
}

Categories

Resources