Dotclear

Vous n'êtes pas identifié(e).

Annonce

13 février 2024 Sortie de Dotclear 2.29

#1 2017-02-14 20:11:25

Diro
Membre
Inscription : 2017-02-14

XMLRPC metaWeblog.newPost

Hello :)
I'm trying to add post by metaWeblog.newPost, my code:


include('phpxmlrpc.php');

$usr = 'login';
$pwd = 'password;
$xmlrpc = 'http://domain.com/index.php?xmlrpc/default';

    $function_name = "metaWeblog.newPost";
    $url = $xmlrpc;

    $client = new xmlrpc_client($url);
    $client->return_type = 'phpvals';

    $message = new xmlrpcmsg(
            $function_name, 
            array(
                new xmlrpcval(1, "int"),
                new xmlrpcval($usr, "string"), 
                new xmlrpcval($pwd, "string"), 
                new xmlrpcval(
                    array(
                        "title" => new xmlrpcval("Title", "string"), 
                        "description" => new xmlrpcval("Desc", "string"), 
                        ), 
                    "struct"
                    ),
                new xmlrpcval(true,"boolean") 
                )
            );
    $resp = $client->send($message);

    if ($resp->faultCode()) echo 'KO. Error: '.$resp->faultString(); else echo "Post id is: " . $resp->value();

But i have error:  Invalid method parameters.
What i'm doing wrong? Thanks for help :)

Hors ligne

#2 2017-02-15 16:02:20

Franck
Footer de merde
Lieu : Paris
Inscription : 2004-11-09
Site Web

Re : XMLRPC metaWeblog.newPost

Hi,

I will make some tests about this in order to give an answer. Asap ;-)


Dotclear addicted since 2004

Hors ligne

#3 2017-02-15 16:15:13

Diro
Membre
Inscription : 2017-02-14

Re : XMLRPC metaWeblog.newPost

Thanks :)

Hors ligne

#4 2017-02-17 07:38:33

Franck
Footer de merde
Lieu : Paris
Inscription : 2004-11-09
Site Web

Re : XMLRPC metaWeblog.newPost

Could you give me the source of the included phpxmlrpc.php (or give an URL where I can download it)?


Dotclear addicted since 2004

Hors ligne

#5 2017-02-17 08:27:38

Diro
Membre
Inscription : 2017-02-14

Re : XMLRPC metaWeblog.newPost

Hors ligne

#6 2017-02-17 09:12:40

Franck
Footer de merde
Lieu : Paris
Inscription : 2004-11-09
Site Web

Re : XMLRPC metaWeblog.newPost

I see, the first parameter should be a string not an int, so replace the according line by :

new xmlrpcval((string) 1, "string"),

rather than :

new xmlrpcval(1, "int"),

Dotclear addicted since 2004

Hors ligne

#7 2017-02-17 09:19:38

Diro
Membre
Inscription : 2017-02-14

Re : XMLRPC metaWeblog.newPost

Thanks i will check it :)

Hors ligne

#8 2017-02-17 20:36:20

Diro
Membre
Inscription : 2017-02-14

Re : XMLRPC metaWeblog.newPost

It's working, thank you very much :)

Hors ligne

#9 2017-02-18 06:32:07

Franck
Footer de merde
Lieu : Paris
Inscription : 2004-11-09
Site Web

Re : XMLRPC metaWeblog.newPost

Diro a écrit :

It's working, thank you very much :)

Cool \o/


Dotclear addicted since 2004

Hors ligne

Vous n'êtes pas identifié(e).

Pied de page des forums

Sites map