cURL请求 - 我该怎么做?

Bif*_*rss 2 php api curl

有人可以指出我正确的方向如何使用以下内容:

curl "https://api.xxxxxx.com/phones/:number/calls" \
-d"call[phone_number]=<number-to-call>" \
-d"token=<api_token>" \
--insecure
Run Code Online (Sandbox Code Playgroud)

我试图找到答案,但我似乎无法为我工作 - 它应该打个电话!理论上!但是找不到用PHP发送请求的方法.

谢谢,B.

jer*_*luc 5

使用PHP的cURL这样的东西:

<?php
$ch = curl_init();

$data = array(
  'call[phone_number]' => '<number-to-call>', 
  'token' => '<api_token>'
);

curl_setopt($ch, CURLOPT_URL, 'https://api.xxxxxx.com/phones/:number/calls');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);
?>
Run Code Online (Sandbox Code Playgroud)