Bash script for POST request https xml-rpc on Gravatar

1.1k views Asked by At

I have a project to collect user information by a HTML local file. The project is aiming to be cross-platform and portable (require to have bash like git bash of github). All collected data would be sent to a bash script by custom protocol set up previously. Now, I want use bash to sign in to Gravatar using xml-rpc. I found this script

#! /bin/bash

# ping technorati

# configuration
ADDRESS="http://www.acooke.org/cute"
NAME="C[omp]UTE"
# (end of configuration)

export PATH="$PATH:$CUTE_DIR/scripts"

tmp=`mktemp`
echo "<?xml version=\"1.0\"?>
<methodCall>
  <methodName>weblogUpdates.ping</methodName>
  <params>
    <param>
      <value>$NAME</value>
    </param>
    <param>
      <value>$ADDRESS</value>
    </param>
  </params>
</methodCall>" > "$tmp"

size=`cat "$tmp" | wc -c`

msg=`mktemp`
echo "POST /rpc/ping HTTP/1.0
User -Agent: bash script across netcat - andrew@...
Host: rpc.technorati.com
Content-Type: text/xml
Content-length: $size
" > "$msg"

cat "$tmp" >> "$msg"
rm "$tmp"
cat "$msg"
cat "$msg" | nc rpc.technorati.com 80
rm "$msg"

I wonder how to transform this into https for Gravatar?

1

There are 1 answers

0
judovana On

Curl should be there for you:

curl --header "Content-Type: application/xml" \
  --request POST \
  --data "
<methodCall>
  <methodName>sample.sum</methodName>
  <params>
    <param>
      <value>2</value>
    </param>
    <param>
      <value>3</value>
    </param>
  </params>
</methodCall>
" http(s)://rpc.technorati.com:80

Should do the job.

It did for my hyper simple service making x+y on strings