2016-12-27 28 views

回答

1

您可以使用以下代碼使用rest api獲取通知ID。

注:假設id爲1801481297

<?php 
$options = array (
    'http' => 
    array (
    'ignore_errors' => true, 
    'header' => 
    array (
     0 => 'authorization: Bearer YOUR_API_TOKEN', 
    ), 
), 
); 

$context = stream_context_create($options); 
$response = file_get_contents(
    'https://public-api.wordpress.com/rest/v1/notifications/1801481297', 
    false, 
    $context 
); 
$response = json_decode($response); 
?> 
+0

能否請你告訴我多一點?我已經在developer.wordpress.com doc選項卡中找到了此代碼。但是如果我通過郵遞員運行這個代碼,它會給我「找不到路由」的錯誤。 –

+0

但是這個代碼是不是從developer.wordpress.com –

+0

看到這一點:?https://developer.wordpress.com/docs/api/1.1/post/notifications/seen/ 陣列( 'ignore_errors'=>真, '方法'=> 'POST', '標題'=> 陣列( 0 => '授權:承載YOUR_API_TOKEN', 1 => '內容類型:應用/ X WWW的窗體-urlencoded', ) '內容'=> http_build_query(陣列( '時間'=> '1420936513', )), ), ); $ context = stream_context_create($ options); $ response = file_get_contents( '',false,$ context ); $ response = json_decode($ response);?> –