1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 21:57:51 +02:00

Closes #4941 - Support for cURL POST, PUT, JSON.

This commit is contained in:
Cameron
2023-01-04 09:31:58 -08:00
parent 3bdb545b07
commit fe8fb34cb4

View File

@@ -586,9 +586,10 @@ class e_file
/** /**
* @param string $address * @param string $address
* @param array|null $options * @param array|null $options
*
* @return CurlHandle|false * @return CurlHandle|false
*/ */
function initCurl($address, $options = null) public function initCurl($address, $options = null)
{ {
$cu = curl_init(); $cu = curl_init();
@@ -638,6 +639,16 @@ class e_file
curl_setopt($cu, CURLOPT_POSTFIELDS, $options['post']); curl_setopt($cu, CURLOPT_POSTFIELDS, $options['post']);
} }
if(!empty($options['postfields']))
{
curl_setopt($cu, CURLOPT_POSTFIELDS, $options['postfields']);
}
if(!empty($options['customrequest'])) // ie. GET, PUT, POST
{
curl_setopt($cu, CURLOPT_CUSTOMREQUEST, $options['customrequest']);
}
if(isset($options['header']) && is_array($options['header'])) if(isset($options['header']) && is_array($options['header']))
{ {
curl_setopt($cu, CURLOPT_HTTPHEADER, $options['header']); curl_setopt($cu, CURLOPT_HTTPHEADER, $options['header']);
@@ -665,7 +676,7 @@ class e_file
* @param array $options [optional] * @param array $options [optional]
* @return string * @return string
*/ */
function getRemoteContent($address, $options = array()) public function getRemoteContent($address, $options = array())
{ {
// Could do something like: if ($timeout <= 0) $timeout = $pref['get_remote_timeout']; here // Could do something like: if ($timeout <= 0) $timeout = $pref['get_remote_timeout']; here