1

在此处使用 API:https ://dev.mention.com/resources/alert_mentions/#put-accounts-id-alerts-alert-id-mentions-mention-id

据我了解,如果我想将特定的“提及”标记为已读,我会这样做:

$browser = new \Buzz\Browser(new \Buzz\Client\Curl);

$params = ['read' => true]; //tried this

$url = "https://api.mention.net/api/accounts/" . $this->getAccountId() . "/alerts/{$alert_id}/mentions/{$mention_id}";


if(!empty($params))
{
    $url .= '?' . http_build_query($params); //i think this isnt needed because i pass $params below to the $browser->put but it was worth a try.
}

$response = $browser->put($url, array(
            "Authorization: Bearer {$this->getAccessToken()}",
            "Accept: application/json",
        ), $params);

if (200 != $response->getStatusCode()) {
    return false;
}

但是,当我运行代码时,它不会产生任何错误并且实际上会返回有效响应,但“读取”标志仍设置为 false。

也试过:

$params = ['read' => 'true']; //tried this
$params = ['read' => 1]; //tried this
4

1 回答 1

1

Mention API 接受请求正文中的 JSON:https ://dev.mention.com/#request-format

您可以将提及标记为已读,如下所示:

$params = ['read' => true];

// params are json encoded
$params = json_encode($params);

$response = $browser->put($url, array(
    "Authorization: Bearer $token",
    "Accept: application/json",
    // the Content-Type header is set to application/json
    "Content-Type: application/json",
), $params);
于 2014-12-08T19:26:09.443 回答