提及API - 将提及标记为READ

时间:2014-12-05 20:56:00

标签: php api mention mentionapp

在此处使用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;
}

然而,当我运行代码时,它不会产生任何错误,并且实际上会返回一个有效的响应,但是" read" flag仍然设置为false。

也尝试过:

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

1 个答案:

答案 0 :(得分: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);