如何使用带有PHP的API v4获得点按的点击次数

问题描述 投票:1回答:1

我将这个URL用于API文档https://dev.bitly.com/v4_documentation.html

我的代码是:

//short URL is bit.ly/2WoKAKu
$url = 'https://api-ssl.bitly.com/v4/bitlinks/2WoKAKu/clicks';
$token = 'my-token';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_GETFIELDS, json_encode(['unit'=>'day','units'=>-1])); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer ".$token,
    "Content-Type: application/json"
]);

$arr_result = json_decode(curl_exec($ch));

但是收到此错误:

stdClass Object
(
    [message] => FORBIDDEN
)
php api curl url-shortener
1个回答
-1
投票

尝试使用以下内容。

$ url ='https://api-ssl.bitly.com/v4/bitlinks/bit.ly/2WoKAKu/clicks';

由域和哈希组成的位链接

© www.soinside.com 2019 - 2024. All rights reserved.