簡體   English   中英

跟蹤腳本安裝

[英]Tracking my script installation

我正在構建CMS / CRM,並希望用戶使用其數據庫在服務器上安裝此軟件。

我想跟蹤該安裝中的某些數據,例如版本,因此如果過時,我可以將更新發送給該安裝。 就像當Wordpress告訴您有新版本可用時一樣。

我還希望能夠跟蹤能夠為安裝付費的用戶數量。

我正在使用PHP,MySQL(PDO)。

您能否讓我知道這個過程叫什么,並且對此過程的任何引用都是很棒的。

在您的應用程序中,您可能需要跟蹤一系列數據; 像這樣的東西

$data = array(
  'domain' => 'http://example.com',
  'version' => '1.4.35',
  'date_added' => '2014-08-20', 
  'last_update' => '2014-08-22'
);

然后,您可以向服務器發送請求,以查看是否有新內容。 使用cURL或任何其他方法發送HTTP請求

$curl = curl_init("http://your-server.com/your-service/");
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); // convert it to JSON format

$json = curl_exec($curl);
curl_close($curl);

// this is your feedback, in JSON format
$response = json_decode($json, true);

最好像這樣檢查狀態,但是要在curl_close()調用之前

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($status == 201){
    // ... all fine
}else{
    // otherwise, do something but don't use exit() or die() in this case
}

解碼后, $response值可能看起來像這樣

array(
  'some_key'     => 'some_value',
  'another_key'  => 'another_value'
  ...
);

現在,根據響應,像這樣向用戶回顯一條消息

if(isset($response['some_key']) && $response['some_key'] == 'some_value')){
    echo "An update is out there, <a href=\"http://your-domain.com/update\">Check it out</a>";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM