cloudflare/cloudflare-php

Custom hostnames - addHostname does not work

4ice opened this issue · 2 comments

4ice commented

When I try to execute the following:

new CustomHostnames($this->adapter)->addHostname(
            "zone_id",
            "mydomain.com",
        );

I get the error message: Unable to decode the JSON request body. Please check your input and try again..

I tried to modify the addHostname-function and remove the ssl-array, and by doing that, I could successfully create a custom hostname.

I am using a free-plan account on cloudflare.

Same for me, removing

//            'ssl' => [
//                'method' => $sslMethod,
//                'type' => $sslType,
//                'settings' => $sslSettings,
//                'wildcard' => $wildcard,
//            ],

fix the issue on free plan

Solution is to change this in the package
array $sslSettings = [], to array|null $sslSettings = null,

If anyone want my fix

update your composer.json

require
"cloudflare/sdk": "dev-patch-addHostname"

and add

    "repositories": {
        "repo-name": {
            "type": "vcs",
            "url": "https://github.com/arommelaere/cloudflare-php"
        }
    }

then composer update