Dec 212012

In my previous post, I blogged about how to access the Socialcast community data without using the API. This is usually necessary when the API doesnt support any particular functionality which is provided by the site.

This is true of the usecase of updating of the user’s profile avatar. Though there is a way to update the user profile in the API, but there is no obvious method of updating the user’s avatar. I asked Socialcast on twitter, but they didn’t answer so I went ahead with trying to use Mechanize to login to the site.

I was finally able to update the profile avatar using the below script. Works like a charm.

require 'Mechanize'
agent =
agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
form =
puts "Please enter user email id" = gets.chomp
puts "Please enter password. caution: it is not masked"
form.password= gets.chomp
puts "Please enter username"
agent.get ("")
form ={ |f| f.file_upload_with(:name => "profile_photo[data]") }
puts "Please enter file path of the image to replace"
form.file_uploads.first.file_name = gets.chomp