Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alnouirah's avatar

needing help for using curl lib !

hello, guys, I need help here :(. I have searched a lot on how to convert the code below into a code that can be used in PHP using the Curl library.

curl -v -u '<YOUR_ACCOUNT_ID>:<YOUR_ACCOUNT_TOKEN>' https://api.karix.io/message/ \
  -H 'content-type: application/json' \
  -d '{
    "channel": "sms",
    "source": "+13253077759",
    "destination": ["+1XXX8323XXX"],
    "content": {
        "text": "Sent from cURL"
    }
}'

but there are some points that I could not understand! I understood some of the options used, for example:

      $ch = curl_init(); // for initialize the request 
      curl_setopt($ch, CURLOPT_URL, $url); // setup the url 
      curl_setopt($ch, CURLOPT_POST, true); // make it post request 
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // adding the headers
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); casting the data to json format and send it with the request .
      $result = curl_exec($ch); // execut the request and store the response into $result variable.

But what I don't understand is this line:

curl -v -u '<YOUR_ACCOUNT_ID>:<YOUR_ACCOUNT_TOKEN>' https://api.karix.io/message/ \

I have that account_id and the token but I don't know where to put them exactly! and what is the meaning of these options :

-v -u

thanks in advance for your help.

0 likes
4 replies
alnouirah's avatar

@sinnbeck Yes, I have tried to download that package before. But it cancels and a message appears in the command line saying that the package does not meet the requirements!

alnouirah's avatar
PS E:\Dawa_v1> composer require guzzlehttp/guzzle
Using version ^7.0 for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for guzzlehttp/guzzle ^7.0 -> satisfiable by guzzlehttp/guzzle[7.0.0, 7.0.0-beta.1, 7.0.0-beta.2, 7.0.0-rc.1, 7.0.1, 7.0.x-dev, 7.1.x-dev].
    - karixtech/karix-php 0.0.2 requires guzzlehttp/guzzle ^6.2 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - karixtech/karix-php 0.0.2 requires guzzlehttp/guzzle ^6.2 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - karixtech/karix-php 0.0.2 requires guzzlehttp/guzzle ^6.2 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - Conclusion: don't install guzzlehttp/guzzle 6.5.x-dev
    - Installation request for karixtech/karix-php ^0.0.2 -> satisfiable by karixtech/karix-php[0.0.2].


Installation failed, reverting ./composer.json to its original content.
alnouirah's avatar

I finally found the solution. After digging for a while into this package.

It seems there I a package for PHP https://packagist.org/packages/karixtech/karix-php It turns out that the ID and the password are Basic auth, so it will be used in this way

curl_setopt($ch, CURLOPT_USERPWD, $id. ":" .$token);

so i created a config file which takes these creadential from the env:

curl_setopt($ch, CURLOPT_USERPWD, config('karix.username'). ":" .config('karix.password'));

and that's it.

Please or to participate in this conversation.