0

I use php 7.4.33

This feature of Bitly Api works with patch method: https://dev.bitly.com/api-reference/#updateBitlinksByGroup

If I use below in my code:

curl_setopt($ch, CURLOPT_PATCH, true);

I get:

PHP Warning: Use of undefined constant CURLOPT_PATCH - assumed 'CURLOPT_PATCH' (this will throw an Error in a future version of PHP) in Api.php on line xx

PHP Warning: curl_setopt() expects parameter 2 to be int, string given in Api.php on line xx

But Bitly Api itself works fine with this and I get the expected response from Bitly, so I assume my json request is correct.

But if I use below instead:

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');

I get this response from Bitly:

{"message":"INVALID_JSON_BODY","resource":"bitlinks","description":"The JSON value provided is invalid."}Array
(
    [message] => INVALID_JSON_BODY
    [resource] => bitlinks
    [description] => The JSON value provided is invalid.
)

What should I do to avoid this php error and make it working on all php 7.4 and php 8.0 and above?

0 Answers0