尝试使用 OAuth2 身份验证访问 Dribbble API v1

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

我正在尝试使用新的 Dribbble API 为自己构建一个简单的 PHP 脚本,这需要 OAuth2。

问题是,目前没有任何 PHP 包装器可以覆盖他们的 v1 API,而且我正在努力构建一个 cURL 身份验证系统。我尝试构建一个基于其他系统包装器的身份验证库,例如这个 Instagram 库 和这个 Twitter 库,但没有成功。

请注意,我需要有一个身份验证系统,因为我需要

write
范围。使用客户端访问令牌仅提供
public
/
read-only
范围。

API 文档:http://developer.dribbble.com/v1/

php curl dribbble-api
1个回答
3
投票

这是我使用 json 的方法 -

<?php
    $perPage = 50; // how many you want to display
    $dribbble_username = 'yourusername'; // dribbble username
    $dribbble_access_token = 'youraccesstoken'; // access token
    $dribbble_data = file_get_contents("https://api.dribbble.com/v1/users/$dribbble_username/shots?access_token=$dribbble_access_token&per_page=$perPage");
    $dribbble = json_decode($dribbble_data, true);
    foreach($dribbble as $shot) : ?>
        <a href="<?php echo $shot['html_url'] ?>" target="_blank">
            <img src="<?php echo $shot['images']['hidpi'] ?>" alt="<?php echo $shot['title'] ?>">
        </a>
<?php endforeach ?>

请记住注册您的应用程序以获取访问令牌。完成后,您可以简单地将 https://api.dribbble.com/v1/users/yourusername/shots?access_token=youraccesscode 放入浏览器中以查看可以播放的内容数组。祝你好运;)

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