2015-03-13 95 views
1

我正在嘗試使用新的Dribbble API(需要OAuth2)爲我自己構建一個簡單的PHP腳本。嘗試使用OAuth2身份驗證訪問Dribbble API v1

問題是,目前沒有任何涵蓋v1 API的PHP包裝器,而且我正努力構建一個cURL認證系統。我試圖建立一個基於其他系統的包裝的認證庫,如Instagram libraryTwitter library,但無濟於事。

請注意,我需要一個認證系統,因爲我需要write範圍。使用客戶端訪問令牌僅提供public/read-only範圍。

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

回答

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放入瀏覽器中查看可以播放的內容數組。祝你好運;)

+0

我很感謝你,但實際上我需要'寫'範圍。客戶端訪問令牌只允許訪問具有「公共」範圍的端點。更新的問題澄清這一點,對不起。 – oscarmarcelo 2015-03-20 19:22:37

相關問題