【问题标题】:Mention API - Mark a mention as READ提及 API - 将提及标记为已读
【发布时间】:2015-02-04 03:11:25
【问题描述】:

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

【问题讨论】:

    标签: php api mention mentionapp


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多