phpdribbble-api

Using Dribbble API with PHP


I want to get my Dribbble shots intro my portfolio website using the Dribbble API. I'm not a PHP guy, that's why I don't know how to use the API (http://dribbble.com/api).

How can I get shots into my HTML or PHP page?


Solution

  • use this JS and change the user info to your name

    // variables used
    
    var slgoetzShots;
    var slgoetzNum = 1;
    var active = "Slgoetz";
    
    
    
    // slgoetz shots
    function slgoetzGet(pageNum){
    var url = "http://api.dribbble.com/slgoetz/shots";
    $.get(
        url, {page:pageNum, per_page:"30"},
        function(data){
            slgoetzShots = data;
            slgoetzNum += 1;
            render(slgoetzShots);
        },
        "jsonp"
    );
    };
    
    
    
    // slgoetzGet: render
    function getSimon(){
    if (active != "slgoetz"){
        slgoetzGet("1");
        $('#'+active).removeClass("active");
        $('#Everyone').addClass("active");
        active = "Simon Goetz";
        slgoetzNum = 1;
    };
    };
    
    //popular shots is default
    getSimon("1")
    
    
    var inner = ""; 
    var innerP1 = '<li><div class="dribbble"><div class="shot"><a href="';
    var innerP2 = '"><img src="';
    var innerP3 = '"></a></div><div class="likes">'  
    var innerP4 = ' Likes</div><div class="comments">'
    var innerP5 = ' Comments</div><div class="name">'
    var innerp6 = '</div></div></li>'
    
    
    function render(filter){
    for (var i = 0; i<filter.shots.length;i++){
        inner = inner + innerP1 + filter.shots[i].url + innerP2 +         filter.shots[i].image_url + innerP3 + filter.shots[i].likes_count + innerP4 +        filter.shots[i].comments_count + innerP5 + filter.shots[i].title + innerp6;
    
    };
    
    $('.gallery').html(inner);
    inner = "";
    };
    
    
    function loadMore(){
    switch(active){
    
    
        case "Simon Goetz":
            inner = $('.gallery').html();
            slgoetzGet(slgoetzNum.toString());
            break;
    };
     };
    

    HTML add a .gallery class to a div