在wordpress中向其他服务器发送请求

时间:2013-01-29 04:14:31

标签: wordpress

我在wordpress中有两个网站

主要网站

 1.)http://www.abc.com

其他网站

 2.)http://www.xyz.com

mainsite我想发送用户名密码othersite,我正在使用此代码

    $creds = array();
    echo $creds['user_login'] = "sachin";
    echo $creds['user_password'] = "pass";
    $user = wp_signon( $creds, false );
   // echo ABSPATH . WPINC;
        if ( is_wp_error($user) ){
        echo $user->get_error_message();
            if( !class_exists( 'WP_Http' ) )
                 include_once( ABSPATH . WPINC. '/class-http.php' );

                        // You would edit the following:
            $username = $creds['user_login']; // Twitter login
            $password = $creds['user_password']; // Twitter password
            $message = "Hey neat, I'm posting with the API";
            // Now, the HTTP request:
            $api_url = 'http://www.xyz.com';
            $body = array( 'status' => $message );
            $headers = array( 'Authorization' => 'Basic '.base64_encode("$username:$password") );
            $request = new WP_Http;
            $result = $request->request( $api_url , array( 'method' => 'POST', 'body' => $body, 'headers' => $headers ) );
           // echo"<pre>";print_r($result['body']);

我不知道我正在以正确的方式发送wp http请求但我的问题是我想要这个用户名和密码(我从主站点发送)到其他服务器(http://www.xyz.com

我如何做到这一点请建议我。请向我提供宝贵的建议,告诉我如何将usernamepassword从一台服务器发送到其他服务器。

由于

1 个答案:

答案 0 :(得分:0)

要共享2个wordpress安装,以便用户可以访问这两个,那么此页面将允许您这样做。

http://www.remicorson.com/share-users-database-on-different-wordpress-installs/

我认为这是你想要做的事情?