mardi 27 septembre 2016

Import Youtube API data into db using Laravel 5.3

I am trying to build a Youtube based application with Laravel 5.3. Using a library I am able to successfully retrieve the data from a playlist and display it. It is formatted like this:

[
    {
        0: {
            kind: "youtube#playlistItem",
            etag: ""I_8x5t5r66_FSaexwefRREftGc0/BO3zvggHrzgTTh_ZhXr745ww"",
            id: "UExDQXc3VFJvaVBIX2VuXzMtcThnWW9ZZUc4YlVmX2dOUC4wMTcyMDhGQUE4NTIzM0Y5",
            snippet: {
                publishedAt: "2014-10-06T15:50:12.000Z",
                channelId: "UCGT2vvwtBJ-0edGHEj5Tv67Q",
                title: "S'More - La ricetta dei biscotti",
                description: "Sul blog la storia, la ricetta e le foto",
                thumbnails: {
                    default: {
                        url: "http://ift.tt/2d3VNvS",
                        width: "120",
                        height: "90"
                     },
                     medium: {
                         url: "http://ift.tt/2dpe41P",
                         width: "320",
                         height: "180"
                     },
                     high: {
                         url: "http://ift.tt/2d3Vz88",
                         width: "480",
                         height: "360"
                     },
                     standard: {
                         url: "http://ift.tt/2dpdh0P",
                         width: "640",
                         height: "480"
                     },
                     maxres: {
                         url: "http://ift.tt/2d3UxJ1",
                         width: "1280",
                         height: "720"
                     }
                  },
                  channelTitle: "Ricette di Famiglia",
                  playlistId: "PLCAB2ddt6H_en_3-q8gRfTYsbUf_gNP",
                  position: "0",
                  resourceId: {
                      kind: "youtube#video",
                      videoId: "Hug-iFvDS3s"
                  }
               }
            },
...
]

My next step would be grabbing the array containing video related data, conveniently map each item to a Video class instance and finally store each video item into my database. Does anyone have any idea how can I acheive that?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire