Esempio n. 1
0
function oauth_page()
{
    global $wpdb;
    if ($_POST['new_consumer']) {
        $store = new OAuthWordpressStore();
        $store->new_consumer($_POST['new_consumer']);
        echo '<div id="message" class="updated fade"><strong><p>New Consumer pair generated.</p></strong></div>';
    }
    //end if new consumer
    echo '<div class="wrap">';
    echo '<h2>OAuth Consumers</h2>';
    $consumers = $wpdb->get_results("SELECT description, consumer_key, secret FROM {$wpdb->prefix}oauth_consumers", ARRAY_A);
    echo '<ul>';
    foreach ($consumers as $consumer) {
        echo '  <li><b>' . ($consumer['description'] ? $consumer['description'] : 'Oauth Consumer') . '</b>';
        echo '    <dl>';
        echo '      <dt>consumer_key</dt>';
        echo '        <dd>' . $consumer['consumer_key'] . '</dd>';
        echo '      <dt>secret</dt>';
        echo '        <dd>' . $consumer['secret'] . '</dd>';
        echo '    </dl>';
        echo '  </li>';
        $aconsumer = $consumer;
        //for test link
    }
    //end foreach consumers
    echo '</ul>';
    echo '<h3>Add OAuth Consumer</h3>';
    echo '<form method="post" action=""><div>';
    echo '<input type="text" name="new_consumer" />';
    echo '<input type="submit" value="Create Key/Secret Pair">';
    echo '</div></form>';
    echo '<h3>Endpoints</h3>';
    echo '<dl>';
    echo '  <dt>Request token endpoint</dt>';
    echo '    <dd>' . get_bloginfo('wpurl') . '/wp-content/plugins/wp-oauth/request_token.php</dd>';
    echo '  <dt>Authorize token endpoint</dt>';
    echo '    <dd>' . get_bloginfo('wpurl') . '/wp-content/plugins/wp-oauth/authorize_token.php</dd>';
    echo '  <dt>Access token endpoint</dt>';
    echo '    <dd>' . get_bloginfo('wpurl') . '/wp-content/plugins/wp-oauth/access_token.php</dd>';
    echo '</dl>';
    $anid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_type='post' ORDER BY post_date DESC LIMIT 1");
    echo '<a href="http://singpolyma.net/oauth/example/wp_auto_client3.php?' . '&amp;blog=' . urlencode(get_bloginfo('home') . '/') . '&amp;api_endpoint=' . urlencode(get_bloginfo('wpurl') . '/wp-comments-post.php') . '&amp;post_id=' . $anid . '">Click here for a test page &raquo;</a>';
}
Esempio n. 2
0
<?php

require_once dirname(__FILE__) . '/common.inc.php';
$store = new OAuthWordpressStore();
$consumer = $store->new_consumer($_REQUEST['description']);
echo 'oauth_consumer_key=' . urlencode($consumer->key) . '&xoauth_consumer_secret=' . urlencode($consumer->secret);