<commit_before><?php

/**
 *
 * U1 PHP auth example
 * This example is taken from Dropbox PHP (http://www.dropbox-php.com/) and adjusted
 * to work with U1 PHP.
 */

// The name of your application or website
$consumerName = 'U1 PHP Example';

/* This should be set to a page on your website. This URL is used by Ubuntu One to redirect the
   user after the authentication process. Ubuntu One calls this page with to URL encoded parameters
   oauth_request, the request token generated by getRequestToken() and oauth_verifier, a token that
   is used by getAccessToken() */
$callbackURL = 'http://google.com';

$oauth = new U1_OAuth_PHP($consumerName);
$dropbox = new U1($oauth);

// We need to start a session
session_start();

// There are multiple steps in this workflow, we keep a 'state number' here
if (isset($_SESSION['state'])) {
    $state = $_SESSION['state'];
} else {
    $state = 1;
}

switch($state) {

    /* In this phase we grab the initial request tokens
       and redirect the user to the 'authorize' page hosted
       on dropbox */
    case 1 :
        echo "Step 1: Acquire request tokens\n";
        $tokens = $oauth->getRequestToken($callbackURL);
        print_r($tokens);

        // Note that if you want the user to automatically redirect back, you can
        // add the 'callback' argument to getAuthorizeUrl.
        echo "Step 2: You must now redirect the user to:\n";
        echo $oauth->getAuthorizeUrl() . "\n";
        $_SESSION['state'] = 2;
        $_SESSION['oauth_tokens'] = $tokens;
        die();

    /* In this phase, the user just came back from authorizing
       and we're going to fetch the real access tokens */
    case 2 :
        echo "Step 3: Acquiring access tokens\n";
        $oauth->setToken($_SESSION['oauth_tokens']);
        $tokens = $oauth->getAccessToken($_REQUEST['oauth_verifier']);
        print_r($tokens);
        $_SESSION['state'] = 3;
        $_SESSION['oauth_tokens'] = $tokens;
        // There is no break here, intentional

    /* This part gets called if the authentication process
       already succeeded. We can use our stored tokens and the api 
       should work. Store these tokens somewhere, like a database */
    case 3 :
        echo "The user is authenticated\n";
        echo "You should really save the oauth tokens somewhere, so the first steps will no longer be needed\n";
        print_r($_SESSION['oauth_tokens']);
        $oauth->setToken($_SESSION['oauth_tokens']);
        break;
    }

}
<commit_msg>fixed a minor bug added required scripts<commit_after><?php

require_once("../src/OAuth-PHP.php");

/**
 *
 * U1 PHP auth example
 * This example is taken from Dropbox PHP (http://www.dropbox-php.com/) and adjusted
 * to work with U1 PHP.
 */

// The name of your application or website
$consumerName = 'U1 PHP Example';

/* This should be set to a page on your website. This URL is used by Ubuntu One to redirect the
   user after the authentication process. Ubuntu One calls this page with to URL encoded parameters
   oauth_request, the request token generated by getRequestToken() and oauth_verifier, a token that
   is used by getAccessToken() */
$callbackURL = 'http://google.com';

$oauth = new U1_OAuth_PHP($consumerName);

// We need to start a session
session_start();

// There are multiple steps in this workflow, we keep a 'state number' here
if (isset($_SESSION['state'])) {
    $state = $_SESSION['state'];
} else {
    $state = 1;
}

switch($state) {

    /* In this phase we grab the initial request tokens
       and redirect the user to the 'authorize' page hosted
       on dropbox */
    case 1 :
        echo "Step 1: Acquire request tokens\n";
        $tokens = $oauth->getRequestToken($callbackURL);
        print_r($tokens);

        // Note that if you want the user to automatically redirect back, you can
        // add the 'callback' argument to getAuthorizeUrl.
        echo "Step 2: You must now redirect the user to:\n";
        echo $oauth->getAuthorizeUrl() . "\n";
        $_SESSION['state'] = 2;
        $_SESSION['oauth_tokens'] = $tokens;
        die();

    /* In this phase, the user just came back from authorizing
       and we're going to fetch the real access tokens */
    case 2 :
        echo "Step 3: Acquiring access tokens\n";
        $oauth->setToken($_SESSION['oauth_tokens']);
        $tokens = $oauth->getAccessToken($_REQUEST['oauth_verifier']);
        print_r($tokens);
        $_SESSION['state'] = 3;
        $_SESSION['oauth_tokens'] = $tokens;
        // There is no break here, intentional

    /* This part gets called if the authentication process
       already succeeded. We can use our stored tokens and the api 
       should work. Store these tokens somewhere, like a database */
    case 3 :
        echo "The user is authenticated\n";
        echo "You should really save the oauth tokens somewhere, so the first steps will no longer be needed\n";
        print_r($_SESSION['oauth_tokens']);
        $oauth->setToken($_SESSION['oauth_tokens']);
        break;
}

{'fraction_non_alphanumeric': 0.10651828298887123, 'fraction_numerical': 0.005365659777424483, 'mean_word_length': 2.862624712202609, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5783963', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1380, 'n_words': 570}