Curl location_ids

Hello, can someone please help me to modify this code so I can also set location_ids ? Thank you.

$curl = curl_init();

        curl_setopt_array($curl, array(
        CURLOPT_URL => "https://connect.squareup.com/v2/orders/search",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_HTTPHEADER => array(
            "Square-Version: 2021-04-21",
            "Authorization: Bearer -----",
            "Content-Type: application/json"
        ),
        ));

Hi @virap1 welcome to the forums!

I’m not super familiar with PHP’s cURL functionality, but wanted to share that we do have a PHP SDK that would make this a lot easier to do (you don’t need to set all the urls/headers etc).

If you prefer sticking to cURL, then note that since it’s more PHP specific rather than Square specific, it’s outside of our general support here unfortunately. I can try testing out some stuff, but you may be better looking up the cURL docs for PHP to see how to post a body. At a simple Google, it looks to be something like:

// create a $body json variable using json_encode
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
...