2

I have two website in wordpress

Main site

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

Other Site

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

From mainsite I want to send username and password to othersite for this i am using this code

    $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']);

I dont know i am sending wp http request in right way or not but my problem is i want this username and password(i am sending from main site) to other server (http://www.xyz.com)

How I can do that please suggest me.please provide me your valuable suggestion how I can send username and password from one server to other server.

Thanks

4

1 に答える 1