birisi ben neredeyse benim kodunda var düşünüyorum ?PHP - data bayrağı ile kıvırmak?
curl -X POST -u "USERNAME:PASS" \
-H "Content-Type: application/json" \
--data '{"aps": {"alert": "this is a message"}}' \
https://mywebsite.com/push/service/
bu linux kabuk komutu işlevselliğini yeniden üreten bir PHP komut dosyası yazabilir ama --data
niteliğini nasıl işleneceğini emin değilim.
İşte benim kod şimdiye kadar gibi görünüyor:
$headers = array();
$headers[] = "Content-Type: application/json";
$body = '{"aps":{"alert":"this is a message"}}';
$ch = curl_init();
// Set the cURL options
curl_setopt($ch, CURLOPT_URL, "https://mywebsite.com/push/service/");
curl_setopt($ch, CURLOPT_USERPWD, "USERNAME:PASSWORD");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
print_r($result);
Kodunuz var mı? iyi yatsın! – dldnh
Tamam şimdi ekledim – John