<commit_before><?php // vim: set ft=php et ts=4 sts=4 sw=4 ai si:
// your data here
$client_id='';
$client_secret='';
$redirect_uri='';

if(isset($_GET['code']))
{
    //set POST variables
    $url = 'https://www.skroutz.gr/oauth2/token';
    $fields = array(
        'code'=>urlencode($_GET['code']),
        'client_id'=>urlencode($client_id),
        'client_secret'=>urlencode($client_secret),
        'redirect_uri'=>urlencode($redirect_uri),
        'grant_type'=>urlencode('authorization_code')
    );

    //url-ify the data for the POST
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL,$url);<commit_msg>Calculate the redirect_uri if not set<commit_after><?php // vim: set ft=php et ts=4 sts=4 sw=4 ai si:
// your data here
$client_id='';
$client_secret='';

// if you want to hardcode the redirect_uri add it here
// otherwise it will be calculated automatically
// and by default point to this script
$redirect_uri='';

/************************************
 * No need to change anything below *
 ************************************/
if (!isset($redirect_uri) || $redirect_uri == '') {
    $redirect_uri = (isset($_SERVER['HTTPSS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
    $redirect_uri .= $_SERVER["HTTP_HOST"] . $_SERVER['SCRIPT_NAME'];
}

if(isset($_GET['code']))
{
    //set POST variables
    $url = 'https://www.skroutz.gr/oauth2/token';
    $fields = array(
        'code'=>urlencode($_GET['code']),
        'client_id'=>urlencode($client_id),
        'client_secret'=>urlencode($client_secret),
        'redirect_uri'=>urlencode($redirect_uri),
        'grant_type'=>urlencode('authorization_code')
    );

    //url-ify the data for the POST
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string,'&');

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL,$url);
{'fraction_non_alphanumeric': 0.21650943396226416, 'fraction_numerical': 0.0037735849056603774, 'mean_word_length': 3.7986425339366514, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 3, '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': '2912191', 'n_tokens_mistral': 704, 'n_tokens_neox': 684, 'n_words': 155}