Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transport error - could not open socket #1

Open
eduardobmoreira opened this issue Jul 15, 2013 · 2 comments
Open

transport error - could not open socket #1

eduardobmoreira opened this issue Jul 15, 2013 · 2 comments
Assignees

Comments

@eduardobmoreira
Copy link

I have a wordpress at localhost then i'm trying to connect with xml-rpc..
It gives the message: "transport error - could not open socket" at line 262 of /WordpressSource/Model/Datasource/WordpressSource.php

Config:

public $wp = array(
        'datasource' => 'WordpressSource.WordpressSource',
        'host' => 'localhost/eduardo/wordpress',
        'path' => '/xmlrpc.php',
        'username' => 'admin',
        'password' => '2w',
        'blog_id' => 0
);

Controller:

$wp = ConnectionManager::getDataSource('wp');
$res = $wp->getPosts(array(
'post_status' => 'publish',
'post_type' => 'post',
'number' => 5,
'orderby' => 'post_modified',
'order' => 'desc',
), array(
'post_title'
));

What it could be?

@angelxmoreno
Copy link
Owner

I will need to install a WP instance on localhost to check if the issue is the name of the host. but for now, please try this:

public $wp = array(
        'datasource' => 'WordpressSource.WordpressSource',
        'host' => 'localhost',
        'path' => '/eduardo/wordpress/xmlrpc.php',
        'username' => 'admin',
        'password' => '2w',
        'blog_id' => 0
);

let the host simply be that, localhost. The path would be the path to the xmlrpc file. Let me know if that works.

@ghost ghost assigned angelxmoreno Jul 16, 2013
@florentsorel
Copy link

I have the same error but WP instance works on localhost.

No solution for remote connection with datasource ?

For example the code bellow works :

<?php
App::uses( 'IXR_Client', 'Vendor' );
App::uses( 'Shell', 'Console' );

class RemoteShell extends AppShell {

    public function main() {
        $client = new IXR_Client('http://ndd.com/remote/xmlrpc.php');

        $USER = '****';
        $PASS = '****';

        if (!$client->query('wp.getCategories','', $USER,$PASS)) 
        {  
            echo('Error occured during category request.' . $client->getErrorCode().":".$client->getErrorMessage());  
        }
        $cats = $client->getResponse();

        if(!empty($cats))
        {
            $this->out('Categories:<br />\n');
            foreach($cats as $_cat) 
                $this->out($_cat['categoryId']);
        }
    }

    public function post() {
        $client = new IXR_Client('http://ndd.com/remote/xmlrpc.php');

        $USER = '****';
        $PASS = '****';
        $content = array(
            'post_type' => 'post',
            'post_title' => 'Test',
            'post_content' => '<p>Test content</p>',
            'terms' => array(
                'category' => array(2)
            )
        );

        if (!$client->query('wp.newPost','', $USER,$PASS, $content)) 
        {  
            echo('Error occured during post request.' . $client->getErrorCode().":".$client->getErrorMessage());  
        }
        $post_id = $client->getResponse();

        if(!empty($post_id))
        {
            $this->out($post_id);
        }
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants