示例#1
0
 /**
  * Connect to WordPress
  * @return bool|\wpClient
  */
 function connect()
 {
     require_once dirname(__FILE__) . '/external/WordpressClient.php';
     $username = \Idno\Core\site()->config()->wordpress['wp_username'];
     $password = \Idno\Core\site()->config()->wordpress['wp_password'];
     $url = \Idno\Core\site()->config()->wordpress['wp_url'];
     $url .= substr($url, -1) == '/' ? '' : '/';
     $endpoint = $url . 'xmlrpc.php';
     # Create client instance
     $wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
     # Set the credentials for the next requests
     $wpClient->setCredentials($endpoint, $username, $password);
     return $wpClient;
 }
示例#2
0
 function wpClientInit($anonymous = false)
 {
     $endpoint = $this->params['recipientUrl'] . "xmlrpc.php";
     $wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient(null, null, null, null);
     if ($anonymous) {
         $wpClient->setCredentials($endpoint, null, null);
     } else {
         $wpClient->setCredentials($endpoint, $this->params['wpLogin'], $this->params['wpPassword']);
     }
     return $wpClient;
 }
            ?>
"></i></li>
                            <?php 
        }
        ?>
                            <?php 
        if ($party) {
            ?>
                                <li class="wcp-party"><i class="icon-glass non-link" title="Coming to the after-party"></i></li>
                                <?php 
        }
        ?>

                        </ul>
                    </div>
                </div>
                <?php 
    }
}
?>
    </div>
<div class="wcp-note" style="clear:both;width:100%"><p>Icons used in the bar graph on top are made by <a href="http://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> and are licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0">CC BY 3.0</a></p></div>
<?php 
$post_content = ob_get_contents();
ob_end_flush();
require_once trailingslashit(get_stylesheet_directory()) . '/includes/WordpressClient.php';
$endpoint = "https://pune.wordcamp.org/2015/xmlrpc.php";
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
$wpClient->setCredentials($endpoint, RPCBOT_USERNAME, RPCBOT_PASSWORD);
$content = array('post_content' => $post_content);
$status = $wpClient->editPost(12, $content);
 /**
  * @vcr test-on-sending-callbacks-vcr.yml
  */
 public function testOnSendingCallbacks()
 {
     $xmlrpcClient = new HieuLe\WordpressXmlrpcClient\WordpressClient(static::$_endpoint);
     $log = array();
     $xmlrpcClient->onSending(function ($event) use(&$log) {
         $log[0] = $event;
     });
     try {
         $xmlrpcClient->getProfile();
     } catch (Exception $ex) {
         $this->assertArrayHasKey('event', $log[0]);
         $this->assertArrayHasKey('endpoint', $log[0]);
         $this->assertArrayHasKey('username', $log[0]);
         $this->assertArrayHasKey('password', $log[0]);
         $this->assertArrayHasKey('method', $log[0]);
         $this->assertArrayHasKey('params', $log[0]);
         return;
     }
     $this->fail('Sending callbacks not called');
 }
示例#5
0
<?php

require __DIR__ . '/lib/autoload.php';
# Your Wordpress website is at: http://wp-website.com
$endpoint = "http://beta.xudoanchuahienlinh.com/xmlrpc.php";
# The Monolog logger instance
$wpLog = new Monolog\Logger('wp-xmlrpc');
# Create client instance
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
# Log error
$wpClient->onError(function ($error, $event) use($wpLog) {
    var_dump($error);
    echo "<br><br>";
    var_dump($event);
    $wpLog->addError($error, $event);
});
# Set the credentials for the next requests
$wpClient->setCredentials($endpoint, 'admin', '12345678@X');
$profile = $wpClient->getProfile(array('user_id', 'username', 'email', 'roles'));
var_dump($profile);
//foreach ($resp as $value) {
echo "<br><br>";
echo $profile["user_id"];
echo "<br><br>";
echo "Username: "******"username"];
echo "<br><br>";
echo "Display name: " . $profile["email"];
echo "<br><br>";
//    };