public function decodeList(&$apiData)
    {
        $resObj = json_decode($apiData);
        if (isset($resObj->error)) {
            $msg = "Error " . $resObj->error->code . " " . $resObj->error->message;
            if (isset($resObj->error->errors[0])) {
                $msg .= " : " . $resObj->error->errors[0]->reason;
            }

            throw new \Exception($msg);
        } else {
            $this->page_info = [
                'resultsPerPage' => $resObj->pageInfo->resultsPerPage,
                'totalResults' => $resObj->pageInfo->totalResults,
                'kind' => $resObj->kind,
                'etag' => $resObj->etag,
                'prevPageToken' => null,
                'nextPageToken' => null,
            ];

            if (isset($resObj->prevPageToken)) {
                $this->page_info['prevPageToken'] = $resObj->prevPageToken;
            }

            if (isset($resObj->nextPageToken)) {
                $this->page_info['nextPageToken'] = $resObj->nextPageToken;
            }

            $itemsArray = $resObj->items;
            if (!is_array($itemsArray) || count($itemsArray) == 0) {
                return false;
            } else {
                return $itemsArray;
            }
        }
    }
public function decodeList(&$apiData)
    {
        $resObj = json_decode($apiData);
        if (isset($resObj->error)) {
            $msg = "Error " . $resObj->error->code . " " . $resObj->error->message;
            if (isset($resObj->error->errors[0])) {
                $msg .= " : " . $resObj->error->errors[0]->reason;
            }

            throw new \Exception($msg);
        } else {
            $this->page_info = [
                'resultsPerPage' => $resObj->pageInfo->resultsPerPage,
                'totalResults' => $resObj->pageInfo->totalResults,
                'kind' => $resObj->kind,
                'etag' => $resObj->etag,
                'prevPageToken' => null,
                'nextPageToken' => null,
            ];

            if (isset($resObj->prevPageToken)) {
                $this->page_info['prevPageToken'] = $resObj->prevPageToken;
            }

            if (isset($resObj->nextPageToken)) {
                $this->page_info['nextPageToken'] = $resObj->nextPageToken;
            }

            $itemsArray = $resObj->items;
            if (!is_array($itemsArray) || count($itemsArray) == 0) {
                return false;
            } else {
                return $itemsArray;
            }
        }
    }
public function decodeList ( & $ apiData ) { $ resObj = json_decode ( $ apiData ) ; if ( isset ( $ resObj -> error ) ) { $ msg = "Error " . $ resObj -> error -> code . " " . $ resObj -> error -> message ; if ( isset ( $ resObj -> error -> errors [ 0 ] ) ) { $ msg .= " : " . $ resObj -> error -> errors [ 0 ] -> reason ; } throw new \ Exception ( $ msg ) ; } else { $ this -> page_info = [ 'resultsPerPage' => $ resObj -> pageInfo -> resultsPerPage , 'totalResults' => $ resObj -> pageInfo -> totalResults , 'kind' => $ resObj -> kind , 'etag' => $ resObj -> etag , 'prevPageToken' => null , 'nextPageToken' => null , ] ; if ( isset ( $ resObj -> prevPageToken ) ) { $ this -> page_info [ 'prevPageToken' ] = $ resObj -> prevPageToken ; } if ( isset ( $ resObj -> nextPageToken ) ) { $ this -> page_info [ 'nextPageToken' ] = $ resObj -> nextPageToken ; } $ itemsArray = $ resObj -> items ; if ( ! is_array ( $ itemsArray ) || count ( $ itemsArray ) == 0 ) { return false ; } else { return $ itemsArray ; } } }
Decode the response from youtube, extract the list of resource objects

@param  string $apiData response string from youtube
@throws \Exception
@return array Array of StdClass objects
Decode the response from youtube extract the list of resource objects