コード例 #1
0
    // Gets the unique option id
    $option_name = $optionsframework_settings['id'];
    if (get_option($option_name)) {
        $options = get_option($option_name);
    }
    if (isset($options[$name])) {
        return $options[$name];
    } else {
        return $default;
    }
}
$environment = of_get_option('sforce_instance');
if ($environment == 'sandbox') {
    $sf_instance_url = 'https://test.salesforce.com/services/oauth2/token';
} else {
    $sf_instance_url = 'https://login.salesforce.com/services/oauth2/token';
}
$curl = new Curl();
$response = $curl->post($sf_instance_url, array('grant_type' => 'password', 'client_id' => SFORCE_CLIENT_ID, 'client_secret' => SFORCE_CLIENT_SECRET, 'username' => $environment == 'sandbox' ? SFORCE_STAGING_USER : SFORCE_PRODUCTION_USER, 'password' => $environment == 'sandbox' ? SFORCE_STAGING_PASSWORD : SFORCE_PRODUCTION_PASSWORD));
$curl->close();
if (isset($response->access_token) && isset($response->instance_url)) {
    update_option('sforce_instance', $environment);
    update_option('sforce_oauth_token', $response->access_token);
    update_option('sforce_instance_url', $response->instance_url);
} else {
    delete_option('sforce_instance');
    delete_option('sforce_oauth_token');
    delete_option('sforce_instance_url');
}
ShareFile::authenticate();
コード例 #2
0
function refresh_sforce_tokens()
{
    SalesForce::authenticate();
    ShareFile::authenticate();
}