Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
CaMer0n opened this issue Jan 3, 2023 · 0 comments
Closed

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

CaMer0n opened this issue Jan 3, 2023 · 0 comments
Assignees
Labels
type: enhancement An improvement or new feature request
Milestone

Comments

@CaMer0n
Copy link
Member

CaMer0n commented Jan 3, 2023

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);
@CaMer0n CaMer0n added the type: enhancement An improvement or new feature request label Jan 3, 2023
@CaMer0n CaMer0n added this to the e107 2.3.3 milestone Jan 3, 2023
@CaMer0n CaMer0n self-assigned this Jan 3, 2023
@CaMer0n CaMer0n closed this as completed in fe8fb34 Jan 4, 2023
@CaMer0n CaMer0n changed the title File handler initCurl() method doesn't support PUT or JSON POST. Add support for PUT or JSON POST to e_file::initCurl() method Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement An improvement or new feature request
Projects
None yet
Development

No branches or pull requests

1 participant