public function getAllUserPages($returnResponse = array(), $cursor = false)
    {

        if (empty($this->login->apiKey)) {
            $this->login->getApiKey();
        }

        //get & parse response
        $response = $this->getPages($cursor);
        $response = json_decode($response['response'], true);

        if (empty($returnResponse) && empty($response['_items'])) {
            echo '<p><strong>You appear to have no Leadpages created yet.</strong></p>
                <p> Please login to <a href="https://my.leadpages.net" target="_blank">Leadpages</a>
                and create a Leadpage to continue.</p>';
            die();
        }

        //if we have more pages add these pages to returnResponse and pass it back into this method
        //to run again
        if ($response['_meta']['hasMore'] == 'true') {
            $returnResponse[] = $response['_items'];
            return $this->getAllUserPages($returnResponse, $response['_meta']['nextCursor']);
        }

        //once we run out of hasMore pages return the response with all pages returned
        if (!$response['_meta']['hasMore']) {
            /**
             * add last result to return response
             */
            $returnResponse[] = $response['_items'];

            /**
             * this maybe a bit hacky but for recursive and compatibility with other functions
             * needed all items to be under one array under _items array
             */
            if (isset($returnResponse) && count($returnResponse) > 0) {
                $pages = array(
                    '_items' => array()
                );
                foreach ($returnResponse as $subarray) {
                    $pages['_items'] = array_merge($pages['_items'], $subarray);
                }

                //strip out unpublished pages
                //sort pages asc by name
                return $this->sortPages($this->stripB3NonPublished($pages));
            }
        }
    }
public function getAllUserPages($returnResponse = array(), $cursor = false)
    {

        if (empty($this->login->apiKey)) {
            $this->login->getApiKey();
        }

        //get & parse response
        $response = $this->getPages($cursor);
        $response = json_decode($response['response'], true);

        if (empty($returnResponse) && empty($response['_items'])) {
            echo '<p><strong>You appear to have no Leadpages created yet.</strong></p>
                <p> Please login to <a href="https://my.leadpages.net" target="_blank">Leadpages</a>
                and create a Leadpage to continue.</p>';
            die();
        }

        //if we have more pages add these pages to returnResponse and pass it back into this method
        //to run again
        if ($response['_meta']['hasMore'] == 'true') {
            $returnResponse[] = $response['_items'];
            return $this->getAllUserPages($returnResponse, $response['_meta']['nextCursor']);
        }

        //once we run out of hasMore pages return the response with all pages returned
        if (!$response['_meta']['hasMore']) {
            /**
             * add last result to return response
             */
            $returnResponse[] = $response['_items'];

            /**
             * this maybe a bit hacky but for recursive and compatibility with other functions
             * needed all items to be under one array under _items array
             */
            if (isset($returnResponse) && count($returnResponse) > 0) {
                $pages = array(
                    '_items' => array()
                );
                foreach ($returnResponse as $subarray) {
                    $pages['_items'] = array_merge($pages['_items'], $subarray);
                }

                //strip out unpublished pages
                //sort pages asc by name
                return $this->sortPages($this->stripB3NonPublished($pages));
            }
        }
    }
public function getAllUserPages ( $ returnResponse = array ( ) , $ cursor = false ) { if ( empty ( $ this -> login -> apiKey ) ) { $ this -> login -> getApiKey ( ) ; } //get & parse response $ response = $ this -> getPages ( $ cursor ) ; $ response = json_decode ( $ response [ 'response' ] , true ) ; if ( empty ( $ returnResponse ) && empty ( $ response [ '_items' ] ) ) { echo '<p><strong>You appear to have no Leadpages created yet.</strong></p>
                <p> Please login to <a href="https://my.leadpages.net" target="_blank">Leadpages</a>
                and create a Leadpage to continue.</p>' ; die ( ) ; } //if we have more pages add these pages to returnResponse and pass it back into this method //to run again if ( $ response [ '_meta' ] [ 'hasMore' ] == 'true' ) { $ returnResponse [ ] = $ response [ '_items' ] ; return $ this -> getAllUserPages ( $ returnResponse , $ response [ '_meta' ] [ 'nextCursor' ] ) ; } //once we run out of hasMore pages return the response with all pages returned if ( ! $ response [ '_meta' ] [ 'hasMore' ] ) { /**
             * add last result to return response
             */ $ returnResponse [ ] = $ response [ '_items' ] ; /**
             * this maybe a bit hacky but for recursive and compatibility with other functions
             * needed all items to be under one array under _items array
             */ if ( isset ( $ returnResponse ) && count ( $ returnResponse ) > 0 ) { $ pages = array ( '_items' => array ( ) ) ; foreach ( $ returnResponse as $ subarray ) { $ pages [ '_items' ] = array_merge ( $ pages [ '_items' ] , $ subarray ) ; } //strip out unpublished pages //sort pages asc by name return $ this -> sortPages ( $ this -> stripB3NonPublished ( $ pages ) ) ; } } }
Recursive function to get all of a users pages

@param array $returnResponse
@param bool  $cursor

@return mixed
Recursive function to get all of a users pages