xxxxxxxxxx
#usage:
curl <url>
#it returns the raw text of the page (or anything else) at <url> in the internet
#to stdout
#examples:
#put the output into <file>
curl <url> > <file>
#to search for <pattern>
curl <url> | grep /<pattern>/
#to uncompress the output
curl <url> | gunzip
#you get the hang of it.
#helpful if you are testing a server :)
#be sure to be on bash or powershell!
xxxxxxxxxx
cURL, which stands for client URL, is a command line tool that developers
use to transfer data to and from a server. At the most fundamental,
cURL lets you talk to a server by specifying the location (in the form of a URL)
and the data you want to send. cURL supports several different protocols,
including HTTP and HTTPS, and runs on almost every platform. This makes cURL
ideal for testing communication from almost any device (as long as it has a
command line and network connectivity) from a local server to most edge devices.
The most basic command in curl is curl http://example.com. The curl command is
followed by the URL, from which we would like to retrieve some kind of data.
In this case, it would return the html source for example.com.
xxxxxxxxxx
// curl command
// curl get
curl 'http://localhost:8082/api/v1/cart'
//curl get with authorization token
curl 'http://localhost:8082/api/v1/cart' \
-H 'Authorization: Bearer <token>'
// curl post with authorization token
curl 'http://localhost:8082/api/v1/cart' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
--data-raw '{"productId":"BW0jAAeDJmlZCF8i","qty":1}' \
xxxxxxxxxx
curl --header "Authorization: key=AAAAbh_xxx-nI:APBAwd91bGn1OssamQlG4R1v84yXOv-6oynz1i4eNltzQLd5ojIiFSHvnCFHJyA33QcRfeAMa5As2mjfEjkRA_XA-YM8gsqEQssm3Ykrn8FSBEwwwkot5KPWY0zMefYB1RZj1ZlZfsWy" --header "Content-Type: application/json" -d '{"to": "f8UQCp0VHqCrBR0Yeiwx0:APA91bHuqLN7Wp40U2Wt8LS3VcRipttiViYF4TXHKP1Rusdov542XEgUYaVk9GIAEM3Q2kHcME5D85BsyWg7vk3H3oLhKJdNQLSNyoxzfnhGAvuQo4BiTZ43sIdVGQ7t86WQDn6s9HBj", "data": {"status": "New information!!!"}}' https://fcm.googleapis.com/fcm/send
xxxxxxxxxx
public function sendSms($mobile)
{
$message ='Your message';
$url = 'www.your-domain.com/api.php?to='.$mobile.'&text='.$message;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec ($ch);
$err = curl_error($ch); //if you need
curl_close ($ch);
return $response;
}