Child pages
  • WHM API 1 Functions - cors_proxy_get
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

 

Description

This function allows your system to perform Cross-Origin Resource Sharing (CORS) HTTP requests.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/cors_proxy_get?api.version=1&url=http%3A%2F%2Fwww.example.com
 XML API

This function does not support XML.

 Command Line
whmapi1 cors_proxy_get url=http%3A%2F%2Fwww.example.com


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
   "metadata":{
      "result":1,
      "reason":"OK",
      "version":1,
      "command":"cors_proxy_get"
   },
   "data":{
      "content":"<!doctype html>\n<html>\n<head>\n    <title>Example Domain</title>\n\n    <meta charset=\"utf-8\" />\n    <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n    <style type=\"text/css\">\n    body {\n        background-color: #f0f0f2;\n        margin: 0;\n        padding: 0;\n        font-family: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n        \n    }\n    div {\n        width: 600px;\n        margin: 5em auto;\n        padding: 50px;\n        background-color: #fff;\n        border-radius: 1em;\n    }\n    a:link, a:visited {\n        color: #38488f;\n        text-decoration: none;\n    }\n    @media (max-width: 700px) {\n        body {\n            background-color: #fff;\n        }\n        div {\n            width: auto;\n            margin: 0 auto;\n            border-radius: 0;\n            padding: 1em;\n        }\n    }\n    </style>    \n</head>\n\n<body>\n<div>\n    <h1>Example Domain</h1>\n    <p>This domain is established to be used for illustrative examples in documents. You may use this\n    domain in examples without prior coordination or asking for permission.</p>\n    <p><a href=\"http://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n",
      "_cp_redirects":null,
      "reason":"OK",
      "url":"http://www.example.com",
      "headers":{
         "expires":"Thu, 06 Jul 2017 17:50:19 GMT",
         "content-type":"text/html",
         "server":"ECS (den/1D9E)",
         "content-length":"1270",
         "vary":"Accept-Encoding",
         "etag":"\"359670651+gzip+ident\"",
         "last-modified":"Fri, 09 Aug 2013 23:54:35 GMT",
         "x-cache":"HIT",
         "cache-control":"max-age=604800",
         "date":"Thu, 29 Jun 2017 17:50:19 GMT"
      },
      "protocol":"HTTP/1.1",
      "success":"1",
      "status":"200"
   }
}
 Output (XML)

This function does not support XML.


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
urlstring

Required

The website that you wish to access.

A valid URL.

http://www.example.com

Returns

ReturnTypeDescriptionPossible valuesExample
content
string

The URL's content.

Notes:

  • We strongly recommend that you confirm the content's type before you use the return value.
  • The function may also return this value in the _cp_redirects array of hashes.

A valid string.

 Click to view...
<p>This domain is established to be used for illustrative examples in documents. You may use this\n    domain in examples without prior coordination or asking for permission.</p>
_cp_redirects
array of hashes

An array redirects that the website performs, if any exist.

Notes:

  • This return counts redirects.
  • This return is for internal use only.
  • If redirects exist, an array of hashes that contains the content , protocol , reason , status , success , and url returns and the headers hash.
  • null — Redirects do not exist.

    Note:

    The JSON example output above displays this condition.

 

reason

string

The response that the server returned.

If redirects exist, the function returns this value in the _cp_redirects array of hashes

A valid string.OK

url

string

The URL that provided the response.

If redirects exist, the function returns this value in the _cp_redirects array of hashes.


A valid URL.http://www.example.com

headers

hash

A hash of the header fields that the request returned.

If redirects exist, the function returns this hash in the _cp_redirects array of hashes.

A hash of valid header fields.

Note:

This hash's returns vary based on the URL's headers.

 

protocol

string

The URL's HTTP protocol.

If redirects exist, the function returns this value in the _cp_redirects array of hashes.

A valid HTTP protocol.

HTTP/1

success

Boolean

Whether the function returned a 2XX HTTP status code.

If redirects exist, the function returns this value in the _cp_redirects array of hashes.

  • 1 — Success.
  • 0 — Failure.

 

1

status

string

The response's HTTP status code.

If redirects exist, the function returns this value in the _cp_redirects array of hashes.

A valid HTTP status code.200
  • No labels