I'm not very adapted to Youtube Api V3. But I watched a google developers live where the google operator shows how to list the activity of a particular channel. Based on this I executed via GET
at the following address:
https://www.googleapis.com/youtube/v3/activities?part=snippet&channelId=UCaNLpnBnxEeQGfEym8bUr-g&maxResults=1&key={SUA_KEY_DE_DESENVOLVIMENTO}
and he returned that code to me. But this code I am not able to do Parse in json in it, since it starts with { ... }
and not the default that in this case would be nome_do_obj:{ ... }
, but being { ... }
has no start of the definition of the object. I used the code:
NOTE: I've used link
to decrypt the code:
using using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public string TentarDecifrar(string textoJson, string key, string value){
JObject jsonData = new JObject(JObject.Parse(textoJson));
return jsonData[key][value];
}
But since the first object has no name / ID it returns NullOperationException
when I execute
void Main(){ MessageBox.Show(TentarDecifrar(CONTEUDO_EM_JSON_QUE_O_YOUTUBE_DATA_API_ME_RETORNA, "items", "description"));}
In the case when I looked at JObject it would be
jsonData[""]["items"]["description"]
/* no caso onde está [""] é onde aparece o objeto que não possui identificação ,ou seja:
{ <= nesta linha
"kind": "youtube#activityListResponse",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/HzaV00F-8u901Ma6Odl2HflceQE\"",
"nextPageToken": "CAEQAA", ... }
*/
I want to get the key items
and the value for example description
, where the CONTEUDO_EM_JSON_QUE_O_YOUTUBE_DATA_API_ME_RETORNA
variable is equal to:
{
"kind": "youtube#activityListResponse",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/HzaV00F-8u901Ma6Odl2HflceQE\"",
"nextPageToken": "CAEQAA",
"pageInfo": {
"totalResults": 6,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#activity",
"etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/yikeFjK_8QolzIG4MyBtbexRdjs\"",
"id": "VTE0NDU3ODg1NTYxMzk4MjAyMjI2NDc2OTY=",
"snippet": {
"publishedAt": "2015-10-25T15:55:56.000Z",
"channelId": "UCaNLpnBnxEeQGfEym8bUr-g",
"title": "Minecraft - MiniGames # 1",
"description": "Todo canal de gamer tem que ter minecraft né ? haha\n\nPag: www.facebook.com/franporfirio98",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/6AzmgmtHTGY/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/6AzmgmtHTGY/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/6AzmgmtHTGY/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/6AzmgmtHTGY/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/6AzmgmtHTGY/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Fran Gamer",
"type": "upload"
}
}
]
}
Summarizing ... I want to develop an application in WinForms so that I can see the youtube api v3 and it returns in json with the data of the last video sent of that particular channel. I still have doubts between Json and Yaml.