Myspace Ads dayparting script

Status
Not open for further replies.

andyt

New member
Dec 20, 2006
677
9
0
One of my myspace campaigns is only profitable during the day so I need to pause and activate the ads every day which is a drag. I created this ruby mechanize script that you can setup as a cronjob that will pause and unpause your campaigns.

To run it:
-install ruby
-install rubygems
-install mechanize 'sudo gem install mechanize'
-save code below as 'myspace.rb'
-fill out your Myspace ads name, password, and campaign ids
-run 'ruby myspace.rb pause' or 'ruby myspace.rb activate'

Code:
require 'rubygems'
require 'mechanize'

myspace_user="user"
myspace_pass="password"
campaign_ids = [102340,200123, 234234]

class Myspace
    def self.pause(user, password, campaign_ids)
        if user.nil? || password.nil?
            print "invalid parameters"
        end
        agent = WWW::Mechanize.new
        page = agent.get('http://advertise.myspace.com')
        form = page.forms.first
        form.fields.name('username').value = user
        form.fields.name('password').value = password
        result = agent.submit(form, form.buttons.first)  
                
        for x in campaign_ids
            page2 = agent.get("https://advertise.myspace.com/campaign.html?campaignId=#{x}")
            form2 = page2.forms.first
            form2.fields.name('pause').value = 'true'
            result2 = agent.submit(form2, form2.buttons.first)
        end
    end

    def self.unpause(user, password, campaign_ids)
        if user.nil? || password.nil?
            print "invalid parameters"
        end
        
        agent = WWW::Mechanize.new
        page = agent.get('http://advertise.myspace.com')
        form = page.forms.first
        form.fields.name('username').value = user
        form.fields.name('password').value = password
        result = agent.submit(form, form.buttons.first)  
                
        for x in campaign_ids
            page2 = agent.get("https://advertise.myspace.com/campaign.html?campaignId=#{x}")
            form2 = page2.forms.first
            form2.fields.name('pause').value = 'false'
            form2.fields.name('toMySpace').value = 'true'
            result = agent.submit(form2, form.buttons.last)

        end
    end

    
end

begin
    if(ARGV[0] == 'pause') 
        Myspace.pause(myspace_user, myspace_pass, campaign_ids) 
    elsif(ARGV[0] == 'activate')
        Myspace.unpause(myspace_user, myspace_pass, campaign_ids) 
    else
        print "usage: myspace.rb pause|activate"
    end
end
I'm not responsible if Myspace bans your account because of this or if their code changes and it mistakenly deletes your campaigns. I tried it just now and it works for me. :rasta:
 


Thanks buddy! I was looking for something like this when MySpace used to send me traffic.
 
Does traffic usually start right away for you guys after resuming a campaign? My ads take quite a while to get started again.
 
I used it before and had ads come back after pausing repeatedly. I also had some really profitable ones that I paused last night never come back. I would actually avoid pausing anything if you don't really have to.
 
Hello andyt

I used it before and had ads come back after pausing repeatedly. I also had some really profitable ones that I paused last night never come back. I would actually avoid pausing anything if you don't really have to.

Thankyou for your quick response:)
 
Status
Not open for further replies.