2016-04-16 34 views
0

我試圖使用Dropbox的Webhooks界面跟蹤用戶的文件更改。我期望這個調用包含POST數據,但是似乎沒有POST數據(或者GET數據)。這裏是我的PHP代碼,其中if部分用於Dropbox驗證webhook,而else部分將$_POST$_GET變量保存到文件中。Dropbox Webhooks不包含發佈數據

<?php 
if(isset($_GET['challenge'])) { 
    echo $_GET['challenge']; 
} else { 
    $output = print_r($_POST, true); 
    file_put_contents('file.txt', $output, FILE_APPEND); 
    $output = print_r($_GET, true); 
    file_put_contents('file.txt', $output, FILE_APPEND); 
} 
?> 

片刻之後,file.txt填補了這一點:

Array 
(
) 
Array 
(
) 

回答

0

this answer到一個相關的問題,你需要得到JSON數據是這樣的:

$output = file_get_contents('php://input'); 

或者,因爲它是JSON:

$output = json_decode(file_get_contents('php://input'));