public function downloadPageHtml($pageId, $isRetry = false)
    {

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

        $response = $this->getSinglePageDownloadUrl($pageId);

        if ($response['error']) {
            return $response;
        }

        $responseArray = json_decode($response['response'], true);
        $url = $responseArray['url'];

        if ($isRetry) {
            $url = str_replace('https:', 'http:', $url);
        }

        $options = [
            'verify' => !$isRetry ? $this->certFile : false,
        ];

        foreach ($_COOKIE as $index => $value) {
            if (strpos($index, 'splitTestV2URI') !== false) {
                $options['cookies'] = [$index => $value];
            }
        }

        try {
            $html = $this->client->get($url, $options);
            $response = [
                'code' => 200,
                'response' => $html->getBody()->getContents(),
            ];

            if (count($this->getPageSplitTestCookie($html)) > 0) {
                $response['splitTestCookie'] = $this->getPageSplitTestCookie($html);
            }

        } catch (ClientException $e) {
            $response = $this->parseException($e);

        } catch (RequestException $e) {
            $response = $this->parseException($e);
            if (!$isRetry) {
                $response = $this->downloadPageHtml($pageId, true);
            }

        } catch (ServerException $e) {
            $response = $this->parseException($e);

        } catch (ConnectException $e) {
            $message = 'Can not connect to Leadpages Server:';
            $response = $this->parseException($e, $message);

        }

        return $response;
    }
public function downloadPageHtml($pageId, $isRetry = false)
    {

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

        $response = $this->getSinglePageDownloadUrl($pageId);

        if ($response['error']) {
            return $response;
        }

        $responseArray = json_decode($response['response'], true);
        $url = $responseArray['url'];

        if ($isRetry) {
            $url = str_replace('https:', 'http:', $url);
        }

        $options = [
            'verify' => !$isRetry ? $this->certFile : false,
        ];

        foreach ($_COOKIE as $index => $value) {
            if (strpos($index, 'splitTestV2URI') !== false) {
                $options['cookies'] = [$index => $value];
            }
        }

        try {
            $html = $this->client->get($url, $options);
            $response = [
                'code' => 200,
                'response' => $html->getBody()->getContents(),
            ];

            if (count($this->getPageSplitTestCookie($html)) > 0) {
                $response['splitTestCookie'] = $this->getPageSplitTestCookie($html);
            }

        } catch (ClientException $e) {
            $response = $this->parseException($e);

        } catch (RequestException $e) {
            $response = $this->parseException($e);
            if (!$isRetry) {
                $response = $this->downloadPageHtml($pageId, true);
            }

        } catch (ServerException $e) {
            $response = $this->parseException($e);

        } catch (ConnectException $e) {
            $message = 'Can not connect to Leadpages Server:';
            $response = $this->parseException($e, $message);

        }

        return $response;
    }
public function downloadPageHtml ( $ pageId , $ isRetry = false ) { if ( is_null ( $ this -> login -> apiKey ) ) { $ this -> login -> apiKey = $ this -> login -> getApiKey ( ) ; } $ response = $ this -> getSinglePageDownloadUrl ( $ pageId ) ; if ( $ response [ 'error' ] ) { return $ response ; } $ responseArray = json_decode ( $ response [ 'response' ] , true ) ; $ url = $ responseArray [ 'url' ] ; if ( $ isRetry ) { $ url = str_replace ( 'https:' , 'http:' , $ url ) ; } $ options = [ 'verify' => ! $ isRetry ? $ this -> certFile : false , ] ; foreach ( $ _COOKIE as $ index => $ value ) { if ( strpos ( $ index , 'splitTestV2URI' ) !== false ) { $ options [ 'cookies' ] = [ $ index => $ value ] ; } } try { $ html = $ this -> client -> get ( $ url , $ options ) ; $ response = [ 'code' => 200 , 'response' => $ html -> getBody ( ) -> getContents ( ) , ] ; if ( count ( $ this -> getPageSplitTestCookie ( $ html ) ) > 0 ) { $ response [ 'splitTestCookie' ] = $ this -> getPageSplitTestCookie ( $ html ) ; } } catch ( ClientException $ e ) { $ response = $ this -> parseException ( $ e ) ; } catch ( RequestException $ e ) { $ response = $ this -> parseException ( $ e ) ; if ( ! $ isRetry ) { $ response = $ this -> downloadPageHtml ( $ pageId , true ) ; } } catch ( ServerException $ e ) { $ response = $ this -> parseException ( $ e ) ; } catch ( ConnectException $ e ) { $ message = 'Can not connect to Leadpages Server:' ; $ response = $ this -> parseException ( $ e , $ message ) ; } return $ response ; }
get url for page, then use a get request to get the html for the page

@todo refactor this
@todo at sometime this should be replaced with a single call to get the html this requires two calls

@param string $pageId  Leadpages Page id not wordpress post_id
@param bool   $isRetry true downgrades to http

@return mixed
get url for page then use a get request to get the html for the page