DATA="
<entry xmlns="http://www.w3.org/2005/Atom"> \
<title type='text'>From linux shell:</title> \
<content type="text">$1</content> \
<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="entry" /> \
<category scheme="http://www.ibm.com/xmlns/prod/sn/message-type" term="status" /> \
</entry>
"
curl --user 'petr_xxx@xx.ibm.com' -H "Content-Type: application/atom+xml" -d "$DATA" -X PUT "https://w3-connections.ibm.com/profiles/atom/mv/theboard/entry/status.do"
class IbmConnections
def initialize(username, password)
@username = username
@password = password
end
def post_status_message
require 'rest_client'
atom = "
<entry xmlns='http://www.w3.org/2005/Atom'>
<title type='text'>Hi</title>
<category term='entry' scheme='http://www.ibm.com/xmlns/prod/sn/type' />
<category term='status' scheme='http://www.ibm.com/xmlns/prod/sn/message-type' />
<content type='text'>Morning! Have a nice day ahead!</content>
</entry>"
begin
url = "https://w3-connections.ibm.com/profiles/atom/mv/theboard/entry/status.do"
resource = authenticate url, @username, @password
response = resource.put atom, :content_type => 'application/atom+xml'
if response.empty?
return {:success => 'true', :message => "Successfully update your status!", :data => atom}
else
return {:success => 'false', :message => "Error occurred while posting to Connections! <br /> Please contact the administrator.", :data => atom}
end
rescue => error
logger.debug "Error: IbmConnections.post_it_connections(2)"
logger.debug error.inspect
return {:success => 'false', :message => "Error occurred while posting to Connections! <br /> Please contact the administrator.", :data => error.inspect}
end
end
def authenticate url, username, password
auth = 'Basic ' + Base64.strict_encode64("#{username}:#{password}")
RestClient::Resource.new(url, { :headers => { 'Authorization' => auth } } )
end
end