Some parts of the api is not working for me (start,stop,results)

66 views
Skip to first unread message

Triggs

unread,
Apr 16, 2013, 6:46:43 AM4/16/13
to pollevery...@googlegroups.com

Hi,

I'm using your api and some things are not working in the ruby gem. My main concerns are:

Getting the poll results

Starting and stopping the poll

Here is a sample of my code to illuminate my understanding of the api documentation


require 'rubygems'
require 'sinatra'
require 'polleverywhere'
require 'json'
require 'sinatra/jsonp'


PollEverywhere.config do
    username  "redacted@redacted.com"
      password  "redacted"
    # Get a list of your polls
end

def clean(str)
    # remove underscores
    s = str.gsub(/_|\./, " ")
    return s
end

get '/' do
  "Welcome to Search solutions' poll everywhere api"
end

get '/find/polls' do
    polls = PollEverywhere::Poll.all
    "#{polls}"
end

get '/get/polls/results/:perma' do
    @results = PollEverywhere::MultipleChoicePoll.from_hash(
        :permalink => "#{params[:perma]}"
    ).save
    @results.results
end

get '/find/poll/:permalink/:action' do
  @mcp = PollEverywhere::MultipleChoicePoll.from_hash(
      :permalink => "#{params[:permalink]}"
  ).save
  if params[:action] == "stop"
      @mcp.stop
      @mcp.save
      "The Poll #{params[:permalink]} has been sucessfully #{params[:action]}ped"
  elsif params[:action] == "start"
      @mcp.start
      @mcp.save
      "The Poll #{params[:permalink]} has been sucessfully #{params[:action]}ed"
  end
end


Any help you can provide would be greatly appreciated as my client has a paid account and
would like to get this up and running asap


Steel Fu

unread,
Apr 18, 2013, 7:07:31 PM4/18/13
to pollevery...@googlegroups.com
Hi Triggs,

Is there a specific error you are running into?

Triggs

unread,
Apr 19, 2013, 1:54:08 PM4/19/13
to pollevery...@googlegroups.com
there is no error message given in the log or when i print the response to the browser screen or log file
for example:


get   '/get/polls/results/:perma' do
     @results = PollEverywhere::
     MultipleChoicePoll.from_hash(  :permalink => "#{params[:perma]}"  ).save

   " @results.results"
end
@results.results' is suppose to print json data and add the double quotes around it prints it to the screen and a puts would print it to my log file. neither is happening for me because  no error is occur as far as Sinatra know it executes successfully but no results printing. the same goes for the find, stop, and start methods. i'm currently looking inside of the gem file for other things to try thats not in api doc

Steel Fu

unread,
Apr 22, 2013, 1:31:13 PM4/22/13
to pollevery...@googlegroups.com
I've just modified the Gem to return the JSON from model.results. We weren't doing this previously.

Try updating the Gem to 0.0.17 and try again.
Reply all
Reply to author
Forward
0 new messages