W3C home > Mailing lists > Public > public-rww@w3.org > July 2012

Re: Using MyProfile from the command line?

From: Melvin Carvalho <melvincarvalho@gmail.com>
Date: Tue, 10 Jul 2012 11:53:48 +0200
Message-ID: <CAKaEYhL_aq_Kd1Rtg7uvO0u2-SeT4zGe-8MWmf67BcDZnnMfCw@mail.gmail.com>
To: Andrei Sambra <andrei@fcns.eu>
Cc: public-rww@w3.org
On 7 July 2012 16:43, Andrei Sambra <andrei@fcns.eu> wrote:

> Hi Melvin,
>
>
> On 07/07/12 14:44, Melvin Carvalho wrote:
>
>> Has anyone been able to make a wall post from the command line?  I tried
>> the following unsuccessfully :
>>
>> echo "user=local&new=1&comment=**curltest"  | curl -X POST -E
>> e.pemhttps://my-profile.eu/**wall.php <http://my-profile.eu/wall.php>
>>
>> Any ideas?
>>
>>  I don't think you'll be able to do that, since posting on the wall
> requires the user to be authenticated through a session. Therefore, your
> script would first have to authenticate (same link as the WebID button) and
> save the session cookie, and only then post the message.
>

I've slightly modified the python script you gave me to get this to work:

#!/usr/bin/env python

import urllib
import httplib2

cert_file = 'e.pem'

http = httplib2.Http(disable_ssl_certificate_validation=True)
http.add_certificate('', cert_file, domain='')

url = '
https://auth.my-profile.eu/auth/index.php?authreqissuer=https://my-profile.eu/index.php
'
response, content = http.request(url)

headers = {'Cookie': response['set-cookie'], 'Content-type':
'application/x-www-form-urlencoded'}

newurl = 'https://my-profile.eu/wall.php'
body = { 'comment' : 'curltest', 'user' : 'local', 'new' : '1' }
response, content = http.request(newurl, 'POST', headers=headers,
body=urllib.urlencode(body))

https://gist.github.com/3082339



>
> Andrei
>
>
>
Received on Tuesday, 10 July 2012 09:54:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 10 July 2012 09:54:16 GMT