晚上好,我有一个 Todoist 帐户。我会使用 Todoist API 来获取所有项目。我写了以下代码:
$url = "https://todoist.com/API/v6/sync";
$post_data = array(
'token' => "12345678901234567890abcdefabcdef01234567",
'seq_no' => "0",
'resource_types' => '["projects"]'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
print_r($output);
curl_close($ch);
输出是这样的字符串:
{"TempIdMapping":{},"seq_no_global":6201059540,"seq_no":6201059540,"UserId":7179424,"Projects":[{"user_id":7179424,"name":"Project1","color": 1,"is_deleted":0,"collapsed":0,"id":165361294,"archived_date":null,"item_order":1,"indent":1,"archived_timestamp":0,"shared":false, "is_archived":0},{"indent":1,"name":"Inbox","user_id":7179424,"color":7,"is_deleted":0,"collapsed":0,"inbox_project": true,"archived_date":null,"item_order":0,"is_archived":0,"archived_timestamp":0,"shared":false,"id":165339673}]}
有没有办法将此输出转换为数组?例子:
TempIdMapping => {},
seq_no_global => 6201059540,
seq_no => 6201059540
等等...