2015-09-20 94 views

回答

0

您必須使用捲曲。這是一個可以做到的基本腳本。

// You must use UTC timezone 
date_default_timezone_set('UTC'); 

$project_key = 'your project key'; 

$data = array(
    'userId' => '12', 
    'traits' => array(
      'name' => 'Jeff', 
      'email' => '[email protected]', 
     ), 
     'timestamp' => date('Y-m-d\TH:i:s') . '.000Z', 
); 

$data = json_encode($data); 
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, "https://input.threads.io/v1/identify"); 
curl_setopt($curl, CURLOPT_USERPWD, "$project_key:''"); 
curl_setopt($curl, CURLOPT_POST, 1); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
curl_exec($curl); 
curl_close($curl); 

一個很好的起點,以瞭解捲曲:http://www.hackingwithphp.com/15/10/2/your-first-curl-scripts

當然php.net:http://php.net/curl