Skip to content

Add support for PUT or JSON POST to e_file::initCurl() method  #4941

Closed
@CaMer0n

Description

@CaMer0n

Motivation

Various REST APIs online require JSON with PUT or POST.

Proposed Solution

Support additional options: postfields and customrequest

eg.

$options = [
    'postfields'       => "{\"email\":\"demo@example.com\", \"name\": \"John\"}",
    'customrequest'    => 'PUT',
    'header'    => [
        "accept: application/json",
        "content-type: application/json"
    ]
];

$cu = e107::getFile()->initCurl($url, $options);
$result = curl_exec($cu);

or use getRemoteContent() which uses initCurl() and has the error handling built-in.

$options = [
    'postfields'       => "{\"email\":\"demo@example.com\", \"name\": \"John\"}",
    'customrequest'    => 'PUT',
    'header'    => [
        "accept: application/json",
        "content-type: application/json"
    ]
];

$result = e107::getFile()->getRemoteContent($url, $options);

Metadata

Metadata

Assignees

Labels

type: enhancementAn improvement or new feature request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions