{"id":7014,"date":"2014-05-17T00:20:39","date_gmt":"2014-05-17T00:20:39","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/having-trouble-with-official-yahoo-boss-api-ruby-documentation-collection-of-common-programming-errors\/"},"modified":"2014-05-17T00:20:39","modified_gmt":"2014-05-17T00:20:39","slug":"having-trouble-with-official-yahoo-boss-api-ruby-documentation-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/having-trouble-with-official-yahoo-boss-api-ruby-documentation-collection-of-common-programming-errors\/","title":{"rendered":"Having trouble with official Yahoo BOSS API Ruby Documentation-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m following the tutorial over here, right on developer.yahoo.com:<\/p>\n<p>I left their <code>oauth_util.rb<\/code> alone but I have changed a couple of things with <code>test.rb<\/code> &#8211; the line 1 and I added the keys, obviously.<\/p>\n<pre><code>require '.\/oauth_util.rb'\nrequire 'net\/http'\n\ndef get_response(args,buckets)\n    url = \"http:\/\/yboss.yahooapis.com\/ysearch\/\"+buckets+\"?\"\n    arg_count = 0\n    args.each do|key,value|\n        url = url + key + \"=\" + value+\"&amp;\"\n        ++arg_count\n    end\n\n    if(arg_count &gt; 0) \n        url.slice!(url.length-1)\n    end \n\n    parsed_url = URI.parse( url )\n\n    puts \"url midway:\"\n    puts url\n\n    o = OauthUtil.new\n    o.consumer_key = \"asfasfasdfasdf\"\n    o.consumer_secret = \"asfasfasf123123\"\n\n    Net::HTTP.start( parsed_url.host ) { | http |\n        req = Net::HTTP::Get.new \"#{ parsed_url.path }?#{ o.sign(parsed_url).query_string }\"\n        response = http.request(req)\n        return response.read_body\n    }\nend\n\nargs = Hash.new\nargs[\"format\"] = \"xml\"\n#args[\"format\"] = \"json\"\nargs[\"q\"] = \"watch1\"\nargs[\"count\"] = \"1\"\n\nbuckets = \"web\"\n\nprint get_response(args,buckets)\n<\/code><\/pre>\n<p>Here is the error I&#8217;m getting currently:<\/p>\n<p><code>{\"bossresponse\":{\"responsecode\":\"400\",\"reason\":\"Invalid 'format' parameter'[\"xml\"]'\"}}<\/code><\/p>\n<p>It&#8217;s mis-parsing it somewhere. I&#8217;ve commented everything out in args except <code>args[\"q\"]<\/code> and <code>args[\"count\"]<\/code>, and the resulting error is this:<\/p>\n<p><code>{\"bossresponse\":{\"responsecode\":\"400\",\"reason\":\"Non-integer value in parameter count\"}}<\/code><\/p>\n<p>Okay. Let&#8217;s change it to <code>args[\"count\"] = 1<\/code>:<\/p>\n<p>Boom! Ruby error:<\/p>\n<pre><code>test.rb:8:in `+': can't convert Fixnum into String (TypeError)\n<\/code><\/pre>\n<p>Change line 8 in test.rb to make <code>value<\/code> a string with .to_s and we get:<\/p>\n<pre><code>test.rb:8: syntax error, unexpected tUPLUS, expecting keyword_end\n        url = url + key + \"=\" + value.to_s +\"&amp;\"\n<\/code><\/pre>\n<p>What is going on? Why is this on the official Ruby docs on Yahoo?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m following the tutorial over here, right on developer.yahoo.com: I left their oauth_util.rb alone but I have changed a couple of things with test.rb &#8211; the line 1 and I added the keys, obviously. require &#8216;.\/oauth_util.rb&#8217; require &#8216;net\/http&#8217; def get_response(args,buckets) url = &#8220;http:\/\/yboss.yahooapis.com\/ysearch\/&#8221;+buckets+&#8221;?&#8221; arg_count = 0 args.each do|key,value| url = url + key + &#8220;=&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7014","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7014"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7014\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}