Load Balancing and Redundancy Servers in VeryPDF Cloud API Platform

VeryPDF Cloud API Platform is now support Load Balancing and Redundancy Servers,

The 1st API Server is: http://online.verypdf.com/api/
The 2st API Server is: http://api.verypdf.com/api/

image

You can execute the following URL from your source code to convert a web page to PDF file, using curl_exec() in PHP or HttpWebRequest in C# or WebClient in VB.NET, etc.,

http://online.verypdf.com/api/?apikey=XXXX-XXXX-XXXX-XXXX&app=html2pdf&infile=https://www.verypdf.com/online/cloud-api/index.html&outfile=verypdf.pdf

if you get no response or timeout problem with "http://online.verypdf.com/" URL, this may because high CPU usage, server maintenance, software upgrade, network connection problem, etc. issues, you can switch to second API Server (http://api.verypdf.com/) automatically from your source code, this will guarantee the uptime of VeryPDF Cloud API Service up to 100%, e.g.,

http://api.verypdf.com/api/?apikey=XXXX-XXXX-XXXX-XXXX&app=html2pdf&infile=https://www.verypdf.com/online/cloud-api/index.html&outfile=verypdf.pdf

Please Notice:

1. You need replace "XXXX-XXXX-XXXX-XXXX" with your real APIKEY to remove the restrictions.

2. "http://online.verypdf.com/api/" and "http://api.verypdf.com/api/" have same API parameters.

The following is a sample PHP example to switch API Servers automatically,

<?php

error_reporting(E_ALL);
ini_set('display_errors', true);
set_time_limit(300);

$strAPIServers = array();
$strAPIServers[] = 'http://online.verypdf.com/api/';
$strAPIServers[] = 'http://api.verypdf.com/api/';

$strCmd = '?apikey=XXXX-XXXX-XXXX-XXXX
&app=html2pdf
&infile=https://www.verypdf.com/online/cloud-api/index.html
&outfile=verypdf.pdf';

$strReturnedContent = '';
foreach ($strAPIServers as $strAPIServer)
{
        $strURL = $strAPIServer.$strCmd;
        $strReturnedContent = VeryPDF_APIServer_Execute_URL($strURL);
        if($strReturnedContent == '')
                continue;
        break;
}

echo $strReturnedContent;
if($strReturnedContent == '')
        die('[Error] Failed to retrieve document contents.');
$strFileURL = GetOutputFileURL($strReturnedContent);
if($strFileURL == '')
        die('[Error] Failed to get document URL.');

//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
function GetOutputFileURL($strTextContents)
{
        if($strTextContents == '')
                return '';
        $searchString = "[Output] ";
        $arrayDatas = explode("\n", $strTextContents);
        if(count($arrayDatas) == 0)
                return '';
        for ($line = 0; $line < count($arrayDatas); $line++)
        {
                if (strpos($arrayDatas[$line], $searchString) === 0)
                {
                        $strData = str_replace($searchString, '', $arrayDatas[$line]);
                        $strData = str_replace('<br>', '', $strData);
                        return $strData;
                }
        }
        return '';
}
function VeryPDF_APIServer_Execute_URL($url)
{
        echo "$url<br>";

        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_HOST']);
        $data = curl_exec($ch);
        $curl_errno = curl_errno($ch);
        $curl_error = curl_error($ch);
        curl_close($ch);

        if ($data === false || $curl_errno > 0)
        {
                echo "curl_exec Error ($curl_errno): $curl_error<br>";
                return '';
        }
        return $data;
}
?>

Here is an article for this Load Balancing feature,

https://www.verypdf.com/wordpress/201408/verypdf-cloud-api-platform-is-now-support-load-balancing-servers-and-redundancy-servers-redundant-high-availability-cloud-server-load-balancing-for-verypdf-cloud-apis-40881.html

If you encounter any problem, please feel free to let us know,

http://support.verypdf.com

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!