mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
hello, you know you can create a simple client to connect to XML-RPC wordpress to publish post for example. but I try to send data from a file with $read, does not preserve the structure of xml me and gives me error, goes like this:

Code:
<?xml version="1.0"?>
<methodCall>
<methodName>metaWeblog.newPost</methodName>
<params>
<param>
<value>
<i4>1</i4>
</value>
</param>...



  and should go like this:

Code:
<?xml version="1.0"?>
<methodCall>
  <methodName>metaWeblog.newPost</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
    <param>...



you know if there's any way to fix this? Greetings

pd: server response...
Code:
<value><string>parse error. not well formed</string></value>

Last edited by Perl; 18/08/15 11:05 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Use $bread instead, but whitespace shouldn't be causing that error.

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
That might just be an example but your xml isn't well formatted indeed, is the real file well formatted? unless you pastebin both the file and the code we can't help you much.

@loki: /bread confused


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
hi, thanks for the help, try $bread and I had the same error, the client sends data socket this is the code:

Code:
alias connect {
    set %xmlinc 1
    set %xmlarchivo C:\Users\admin\Desktop\testxml.txt 
    sockopen xml $+ $rand(0,99999) domain.com 80
}

on 1:sockopen:xml*: {
    sockwrite -n $sockname POST /es/xmlrpc.php HTTP/1.1
    sockwrite -n $sockname Content-Type: text/xml
    sockwrite -n $sockname User-Agent: XML-RPC.NET
    sockwrite -n $sockname Host: domain.com
    sockwrite -n $sockname Content-Length: $len(%xmlarchivo)
    sockwrite -n $sockname Connection: Keep-Alive
    sockwrite -n $sockname $crlf
    
    while (%xmlinc <= $lines(%xmlarchivo)) {
      sockwrite -n $sockname $read(%xmlarchivo,%xmlinc)
      inc %xmlinc
    } 
}

on 1:sockread:xml*: {
  sockread %xmldatos
  echo -s %xmldatos 
}


and the server's response is the same:

Code:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Content-Length: 403
Date: Wed, 19 Aug 2015 22:39:03 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>-32700</int></value>
</member>
<member>
<name>faultString</name>
<value><string>parse error. not well formed</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>



and the contents of the file is a publication xmlarchivo.txt in wordpress for XML-RPC protocol metaWeblog:


Code:
<?xml version="1.0"?>
<methodCall>
  <methodName>metaWeblog.newPost</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
    <param>
      <value>
        <string>user</string>
      </value>
    </param>
    <param>
      <value>
        <string>pass</string>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>title</name>
            <value>
              <string>nuevo tituloooooooooo</string>
            </value>
          </member>
          <member>
            <name>description</name>
            <value>
              <string>&lt;iframe src="https://www.youtube.com/watch?v=v_Ci0z2rLLs" frameborder=0 width=510 height=400 scrolling=no&gt;&lt;/iframe&gt;</string>
            </value>
          </member>
          <member>
            <name>categories</name>
            <value>
              <array>
                <data>
                  <value>
                    <string>accion</string>
                  </value>
                </data>
              </array>
            </value>
          </member>
          <member>
            <name>post<name>mt_keywords</name>
            <value>
              <string>tag1,tag2</string>
            </value>
          </member>
          <member>
            <name>custom_fields</name>
            <value>
              <array>
                <data>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>duration</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string>1:02</string>
                        </value>
                      </member>
                    </struct>
                  </value>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>image</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string>http://www.images.com.jpg</string>
                        </value>
                      </member>
                    </struct>
                  </value>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>ID</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string />
                        </value>
                      </member>
                    </struct>
                  </value>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>video</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string>http://www.youtube.com/watch?v=T_2jF-_LnNg</string>
                        </value>
                      </member>
                    </struct>
                  </value>
                </data>
              </array>
            </value>
          </member>
        </struct>
      </value>
    </param>
    <param>
      <value>
        <boolean>1</boolean>
      </value>
    </param>
  </params>
</methodCall>


publish feel much, but that I think is complete and no missing data, if you can give me some help, I is not doing wrong, and no more try ... Greetings

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
$len(%xmlarchivo) returns the length of the filename string, not the size of the file, use $file(%xmlarchivo).size

You'll need to /bread with this method because $read() will strip the whitespace and mess up the content-length

Last edited by Loki12583; 19/08/15 11:30 PM.
Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
Thanks Loki12583, because tests have to do with bread, to see if I can work well, thank you both for the great help. Regards.

Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
Hi, I managed to pass binary variable data file. and I've replaced $len, use $file(%xmlarchivo).size . but I can not read the second line of the file my code is this:


Code:
alias testb {
  bread -t $qt(%xmlarchivo) 0 99999999 &tempFile
  echo -s $bvar(&tempFile,1,10000).text
}


result:

Code:
<?xml version="1.0"?>

is always line 1 of file.

and the result gives the first line of the file, but if I remove parameter "-t" in bread, me too long is a line that fails to send sockwrite to be too long. there any solution? and I not know what else to try, thanks and greetings.

Last edited by Perl; 23/08/15 11:16 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You send it directly with /sockwrite $sockname &tempFile

Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
Originally Posted By: Loki12583
You send it directly with /sockwrite $sockname &tempFile


Loki12583 many thank you very much, now works well, can feel to much, but I'm new to many things and did not know how to do it, that was the solution.

Thanks wims and Loki12583, a greeting.


Link Copied to Clipboard