NameSilo

PHP Function to Submit Site to Del.icio.us

Located in Source Code, started by Michael, Sep 9, 2007

Replies:
5
Views:
4,056

  1. Michael

    Michael NameBio.com NameBio Staff PRO VIP ICA Member ★★★★★★★★★★

    Posts:
    2,363
    Likes Received:
    2,382
    Please Note:
    1. $site must start with http://
    2. $tags must be separated with spaces, not commas
    3. $proxy_addy must start with http://
    4. $use_proxy must be passed in as TRUE if you want to use a proxy
    5. Make sure you have CURL installed.

    I wrote this and I am giving you guys permission to use it however you want commercial or otherwise, just don't sell the code itself. Have fun!

    Demo using this function can be found at BMBot.com.

    rep appreciated :)

    PHP:
    <?php

    function delicious_submit($user$pass$site$note$desc$tags$proxy_addy$proxy_port$use_proxy FALSE)
    {
        
    // Set curl options.
        
    $user_agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
        
    $ch curl_init();
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($chCURLOPT_SSL_VERIFYHOST2);
        
    curl_setopt($chCURLOPT_USERAGENT$user_agent);
        
    curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);
        
    curl_setopt($chCURLOPT_COOKIEJARdirname(__FILE__).'/cookie.txt');
        
    curl_setopt($chCURLOPT_COOKIEFILEdirname(__FILE__).'/cookie.txt');
        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
        if(
    $use_proxy){
            
    curl_setopt($chCURLOPT_HTTPPROXYTUNNEL1);
            
    curl_setopt($chCURLOPT_PROXY$proxy_addy);
            
    curl_setopt($chCURLOPT_PROXYPORT$proxy_port);
        }

        
    // Visit login page.
        
    $url 'https://secure.del.icio.us/login';
        
    $params '';
        
    curl_setopt($chCURLOPT_POSTFIELDS$params);
        
    curl_setopt($chCURLOPT_URL$url);
        
    $result curl_exec($ch);
        
        
    //Grab unique token.
        
    $piece strstr($result"inkey\"");
        
    $piece strstr($piece"value=\"");
        
    $token substr($piece732);

        
    // Log in with token, user and pass.    
        
    $url 'https://secure.del.icio.us/login';
        
    $params 'inkey=' $token '&user_name=' $user '&password=' $pass '&login=log%20in';    
        
    curl_setopt($chCURLOPT_POSTFIELDS$params);
        
    curl_setopt($chCURLOPT_URL$url);    
        
    $result curl_exec($ch);    

        
    // Submit the url.
        
    $url 'http://del.icio.us/' $user '?url=' $site '&submit=save&jump=no';
        
    curl_setopt($chCURLOPT_HTTPGET1);
        
    curl_setopt($chCURLOPT_URL$url);
        
    $result curl_exec($ch);

        
    // Grab the new token.
        
    $piece strstr($result"key\"");
        
    $piece strstr($piece"value=\"");
        
    $token substr($piece732);

        
    // Grab the unique key code.
        
    $piece strstr($result$user "?");
        
    $piece substr($piecestrlen($user));
        
    $piece strstr($piece$user "?");
        
    $quote strpos($piece"\"");
        
    $len strlen($user);
        
    $code substr($piece$len 1$quote $len 1);

        
    // Submit the url, description, notes, and tags along with the new token and key code.
        
    $url 'http://del.icio.us/' $user '?' $code;
        
    $params 'url=' $site '&oldurl=' $site '&description=' $desc '&notes=' $note '&tags=' $tags '&jump=no&key=' $token;
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($chCURLOPT_POSTFIELDS$params);
        
    curl_setopt($chCURL_OPT_URL$url);
        
    $result curl_exec($ch);

        
    curl_close($ch);
    }

    ?>
     
    Last edited: Sep 9, 2007
    The views expressed on this page by users and staff are their own, not those of NamePros.
  2. Daniel

    Daniel Danltn.com VIP ★★★★★★★★★★

    Posts:
    1,310
    Likes Received:
    137
    Very nice, reputation left. I was thinking of writing one of these. :)
     
  3. seohyderabad

    seohyderabad New Member ★★★★★★★★★★

    Posts:
    3
    Likes Received:
    0
    hi

    How to install this & how can i use 2 or three accounts at once :hehe:
     
  4. Michael

    Michael NameBio.com NameBio Staff PRO VIP ICA Member ★★★★★★★★★★

    Posts:
    2,363
    Likes Received:
    2,382
    If by asking how to install it you're asking me to give you the rest of the code to have a working site, sorry... I'm not that generous :)

    This is the hard part. If you need help making an html form and using a while loop you're best bet is www.Codewalkers.com or reading the manual.
     
  5. liam_d

    liam_d The original NP Emo Kid ★★★★★★★★★★

    Posts:
    1,749
    Likes Received:
    28
    Brilliant! Think i will use this for sure!!
     
  6. Porte

    Porte VIP Member VIP ★★★★★★★★★★

    Posts:
    3,553
    Likes Received:
    149
    Thanks for your precious code, rep left. :tu:
     

Want to reply or ask your own question?

It only takes a minute to sign up – and it's free!
NameWorth
  1. NamePros uses cookies and similar technologies. By using this site, you are agreeing to our privacy policy, terms, and use of cookies.
    Dismiss Notice
Loading...