How to attach SKU to Product via BigCommerce API; The field 'product_option_id' is invalid - ruby

I've been banging my head against this for a while so am hoping someone can help. Ruby/HTTParty/BigCommerce Gem (where it works).
Error is: The field 'product_option_id' is invalid ; when trying to add an SKU via
myresponse = HTTParty.post("#{#store_url}products/800/skus",
:body=>{
:sku => "111204",
:options => [
{
:product_option_id => 16,
:option_value_id => 46
}
]
}.to_json,
:headers => {'Content-Type' => 'application/json' },
:basic_auth => #auth)
Basically I can't see/figure out where 'product_option_id' is referring to; you can't directly link options to products via the API that I can see.
There are two other questions on SO re this issue but neither had useful answers for me.
Prior to this, I've;
Created a product; id is 800, sku is 111240P. Response to \products?sku=111240P is
{"id"=>"800", "keyword_filter"=>"NULL", "name"=>"Opaque Thigh High", "type"=>"physical", "sku"=>"111204P", "description"=>"Opaque nylon thigh high.", "search_keywords"=>nil, "availability_description"=>nil, "price"=>"3.8200", "cost_price"=>"2.1800", "retail_price"=>"0.0000", "sale_price"=>"0.0000", "calculated_price"=>"3.8200", "sort_order"=>"0", "is_visible"=>"true", "is_featured"=>"false", "related_products"=>"NULL", "inventory_level"=>"0", "inventory_warning_level"=>"0", "warranty"=>"NULL", "weight"=>"0.1000", "width"=>"4.0000", "height"=>"0.2500", "depth"=>"8.0000", "fixed_cost_shipping_price"=>"0.0000", "is_free_shipping"=>"false", "inventory_tracking"=>"simple", "rating_total"=>"0", "rating_count"=>"0", "total_sold"=>"0", "date_created"=>"Sat, 27 Sep 2014 11:45:14 +0000", "brand_id"=>"135", "view_count"=>"0", "page_title"=>nil, "meta_keywords"=>"NULL", "meta_description"=>"NULL", "layout_file"=>"product.html", "is_price_hidden"=>"false", "price_hidden_label"=>nil, "categories"=>{"value"=>"2"}, "date_modified"=>"Sat, 27 Sep 2014 11:45:14 +0000", "event_date_field_name"=>nil, "event_date_type"=>"none", "event_date_start"=>nil, "event_date_end"=>nil, "myob_asset_account"=>nil, "myob_income_account"=>nil, "myob_expense_account"=>nil, "peachtree_gl_account"=>nil, "condition"=>"New", "is_condition_shown"=>"true", "preorder_release_date"=>nil, "is_preorder_only"=>"false", "preorder_message"=>nil, "order_quantity_minimum"=>"0", "order_quantity_maximum"=>"0", "open_graph_type"=>"product", "open_graph_title"=>nil, "open_graph_description"=>nil, "is_open_graph_thumbnail"=>"true", "upc"=>"714718006338", "date_last_imported"=>nil, "option_set_id"=>"NULL", "tax_class_id"=>"0", "option_set_display"=>"right", "bin_picking_number"=>nil, "custom_url"=>"/Opaque-Thigh-High/", "primary_image"=>{"id"=>"0", "zoom_url"=>"NULL", "thumbnail_url"=>"NULL", "standard_url"=>"NULL", "tiny_url"=>"NULL"}, "availability"=>"available", "brand"=>{"link"=>{"content"=>"/brands/135", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/brands/135.xml"}}, "downloads"=>{"link"=>{"content"=>"/products/800/downloads", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/downloads.xml"}}, "images"=>{"link"=>{"content"=>"/products/800/images", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/images.xml"}}, "discount_rules"=>{"link"=>{"content"=>"/products/800/discountrules", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/discountrules.xml"}}, "configurable_fields"=>{"link"=>{"content"=>"/products/800/configurablefields", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/configurablefields.xml"}}, "custom_fields"=>{"link"=>{"content"=>"/products/800/customfields", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/customfields.xml"}}, "videos"=>{"link"=>{"content"=>"/products/800/videos", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/videos.xml"}}, "skus"=>{"link"=>{"content"=>"/products/800/skus", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/skus.xml"}}, "rules"=>{"link"=>{"content"=>"/products/800/rules", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/rules.xml"}}, "option_set"=>"NULL", "options"=>{"link"=>{"content"=>"/products/800/options", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/products/800/options.xml"}}, "tax_class"=>{"link"=>{"content"=>"/taxclasses/0", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/taxclasses/0.xml"}}}},
Created Options and Option Values; The option is called 'Color', id of 25, and the values I want to add to the Option set are; Green (id 46), Black (id 45) and Red (id 44)
HTTParty.get("#{#store_url}options/25", :basic_auth => #auth)
=> #{"id"=>"25", "name"=>"Color", "display_name"=>"Color", "type"=>"RT", "values"=>{"link"=>{"content"=>"/options/25/values", "rel"=>"resource", "href"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/options/25/values.xml"}}}},
Option values:
HTTParty.get("#{#store_url}options/25/values", :basic_auth => #auth)
=> #{"value"=>[{"id"=>"42", "option_id"=>"25", "label"=>"Gold", "sort_order"=>"0", "value"=>"Gold"}, {"id"=>"43", "option_id"=>"25", "label"=>"Silver", "sort_order"=>"0", "value"=>"Silver"}, {"id"=>"44", "option_id"=>"25", "label"=>"Red", "sort_order"=>"0", "value"=>"Red"}, {"id"=>"45", "option_id"=>"25", "label"=>"Black", "sort_order"=>"0", "value"=>"Black"}, {"id"=>"46", "option_id"=>"25", "label"=>"Green", "sort_order"=>"0", "value"=>"Green"}, {"id"=>"47", "option_id"=>"25", "label"=>"White", "sort_order"=>"0", "value"=>"White"}]}}
Created an option set called '111240P'; its id is 26
api.create_optionset(:name=>"111204P")
{"id"=>26, "name"=>"111204P", "options"=>{"url"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/optionsets/26/options.json", "resource"=>"/optionsets/26/options"}}
Linked the Options to the Option Set via;
new_option_set_value = api.create_optionset_option(26, options={
:option_id => 25,
:display_name => "Colors",
:sort_order => 1,
:is_required => true
})
which returns
{"id"=>16, "option_id"=>25, "option_set_id"=>26, "display_name"=>"Colors", "sort_order"=>1, "is_required"=>true, "option"=>{"url"=>"https://store-w1w68tq.mybigcommerce.com/api/v2/options/25.json", "resource"=>"/options/25"}, "values"=>[{"label"=>"Gold", "sort_order"=>0, "value"=>"Gold", "option_value_id"=>42}, {"label"=>"Silver", "sort_order"=>0, "value"=>"Silver", "option_value_id"=>43}, {"label"=>"Red", "sort_order"=>0, "value"=>"Red", "option_value_id"=>44}, {"label"=>"Black", "sort_order"=>0, "value"=>"Black", "option_value_id"=>45}, {"label"=>"Green", "sort_order"=>0, "value"=>"Green", "option_value_id"=>46}, {"label"=>"White", "sort_order"=>0, "value"=>"White", "option_value_id"=>47}]}
So then I go to do the SKU code at the beginning of the question and I get the error mentioned.
I've tried 16, 26, and 25 as the product option ID's without any luck.
The SKU resource is the only one I can see that allows you to tie all this back to a product.
Any help greatly appreciated.
MORE INFO
HTTParty.get("#{#store_url}products/800/options", :basic_auth => #auth)
=> #<HTTParty::Response:0x10 parsed_response=nil, #response=#<Net::HTTPNoContent 204 No Content readbody=true>
CLOSING OUT THE QUESTION
After beret's advice it all works properly. Note that based on my understanding, the below is contrary to the docs.
Put call; 26 being my option_set I'm attaching to the product
myresponse = HTTParty.put("#{#store_url}products/800",
:body=>{
:option_set_id => 26
}.to_json,
:headers => {'Content-Type' => 'application/json' },
:basic_auth => #auth)
Check the options on the product:
HTTParty.get("#{#store_url}products/800/options", :basic_auth => #auth)
Response:
{"options"=>{"option"=>{"id"=>"7", "option_id"=>"25", "display_name"=>"Colors", "sort_order"=>"1", "is_required"=>"true"}}}
Go back to SKU and add it, note the 7 from the product/option;
myresponse = HTTParty.post("#{#store_url}products/800/skus",
:body=>{
:sku => "111204",
:options => [
{
:product_option_id => 7,
:option_value_id => 46
}
]
}.to_json,
:headers => {'Content-Type' => 'application/json' },
:basic_auth => #auth)
Response:
{"sku"=>{"id"=>"7", "product_id"=>"800", "sku"=>"111204", "cost_price"=>"0.0000", "upc"=>nil, "inventory_level"=>"0", "inventory_warning_level"=>"0", "bin_picking_number"=>nil, "options"=>{"option"=>{"product_option_id"=>"7", "option_value_id"=>"46"}}}}

product_option_id is referring to Product Option ID, see Product Option Resource (API Reference).
You should be able to get it by requesting /api/v2/products/800/options.xml
If the endpoint above returns empty content, it means, that the product has not been linked with any Option Set. You can do so, by updating the product via PUT request to /api/v2/products/800 with payload like this:
{ "option_set_id": 14 }
If you are not sure what's the option_set_id, checkout: /api/v2/options
All these features around Options/Option Sets are very generic, which may be confusing at first, but on the other hand handy in some advanced scenarios.

Related

TYPO3 E-Mail Spam Protection

I’ve got a Problem with spam protection in TYPO3 v9.5 for a long time in my own template extension and custom content elements.
I would expect, that the E-Mail Links inserted via TypoLink in ckEditor would be transformed to name(at)domain.de in the frontend by using the following snippet in my Setup. But its simply is ignored:
config.spamProtectEmailAddresses = 2
config.spamProtectEmailAddresses_atSubst = <span>(at)</span>
I’ve set up a clean Installation with 9.5.15 and it just works. So I think it has something to do with my template-extension or my custom components with custom ckEditor config.
Can someone with a better understanding of TYPO3 please guide me to the right direction?
Here is my TCA for the Textfield:
'bodytext' => [
'exclude' => true,
'label' => 'Kontaktdaten',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 3,
'softref' => 'rtehtmlarea_images,typolink_tag,email[subst],url',
],
'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]'
],
compare your TCA field configuration with the configuration of the field tt_content.bodytext
I guess you missed: config.softref = typolink_tag,images,email[subst],url

How to update all fields in MailChimp API batch subscribe using Ruby and Gibbon

I am using Ruby 1.9.3 without Rails and version 1.0.4 of the Gibbon gem.
I have referrals populated with my list and can send the following to MailChimp with Gibbon. However, only the email address and email type fields are populated in the list in MailChimp. What am I doing wrong that is prohibiting all the merge fields from being imported via API?
Here is the batch and map of the list.
referrals.each_slice(3) do |batch|
begin
prepared_batch = batch.map do |referral|
{
:EMAIL => {:email => referral['client_email']},
:EMAIL_TYPE => 'html',
:MMERGE6 => referral['field_1'],
:MMERGE7 => referral['field_2'],
:MMERGE8 => referral['field_3'],
:MMERGE9 => referral['field_4'],
:MMERGE11 => referral['field_5'],
:MMERGE12 => referral['field_6'],
:MMERGE13 => referral['field_7'],
:MMERGE14 => referral['field_8'],
:MMERGE15 => referral['field_9'],
:FNAME => referral['client_first_name']
}
end
#log.info("prepared_batch : #{prepared_batch}")
result = #gibbon.lists.batch_subscribe(
:id => #mc_list_id,
:batch => prepared_batch,
:double_optin => false,
:update_existing => true
)
#log.info("#{result}")
rescue Exception => e
#log.warn("Unable to load batch into mailchimp because #{e.message}")
end
end
The above executes successfully. However, only the email address and email type are populated but most of the fields should be populated.
Here is my log output for one of the prepared_batches. I replaced the real values with Value. I used my own email for testing.
I, [2013-11-11T09:01:14.778907 #70827] INFO -- : prepared_batch : [{:EMAIL=>
{:email=>"jason+6#marketingscience.co"}, :EMAIL_TYPE=>"html", :MMERGE6=>"Value",
:MMERGE7=>"Value", :MMERGE8=>nil, :MMERGE9=>nil, :MMERGE11=>"8/6/13 0:00",
:MMERGE12=>"Value", :MMERGE13=>nil, :MMERGE14=>"10/18/13 19:09", :MMERGE15=>"Value",
:FNAME=>"Value"}, {:EMAIL=>{:email=>"jason+7#marketingscience.co"}, :EMAIL_TYPE=>"html",
:MMERGE6=>"Value", :MMERGE7=>"Value", :MMERGE8=>nil, :MMERGE9=>nil, :MMERGE11=>"8/6/13
0:00", :MMERGE12=>"Value", :MMERGE13=>nil, :MMERGE14=>nil, :MMERGE15=>"Value",
:FNAME=>"Value"}, {:EMAIL=>{:email=>"jason+8#marketingscience.co"}, :EMAIL_TYPE=>"html",
:MMERGE6=>"Value", :MMERGE7=>"Value", :MMERGE8=>nil, :MMERGE9=>nil, :MMERGE11=>"8/7/13
0:00", :MMERGE12=>"Value", :MMERGE13=>nil, :MMERGE14=>nil, :MMERGE15=>"Value",
:FNAME=>"Value"}]
Here is the log output of result from the MailChimp call.
I, [2013-11-11T09:01:14.778691 #70827] INFO -- : {"add_count"=>3, "adds"=>
[{"email"=>"jason+3#marketingscience.co", "euid"=>"ab512177b4", "leid"=>"54637465"},
{"email"=>"jason+4#marketingscience.co", "euid"=>"eeb8388524", "leid"=>"54637469"},
{"email"=>"jason+5#marketingscience.co", "euid"=>"7dbc84cb75", "leid"=>"54637473"}],
"update_count"=>0, "updates"=>[], "error_count"=>0, "errors"=>[]}
Any advice on how to get all the fields to update in MailChimp is appreciated. Thanks.
Turns out the documentation for using the Gibbon gem to batch subscribe is not correct. You need to add the :merge_vars struct to contain the fields other than email and email type. My final code looks like the following. I'm also going to update this code in its entirety at: https://gist.github.com/analyticsPierce/7434085.
referrals.each_slice(3) do |batch|
begin
prepared_batch = batch.map do |referral|
{
:EMAIL => {:email => referral['email']},
:EMAIL_TYPE => 'html',
:merge_vars => {
:MMERGE6 => referral['field_1'],
:MMERGE7 => referral['field_2'],
:MMERGE8 => referral['field_3'],
:MMERGE9 => referral['field_4'],
:MMERGE11 => referral['field_5'],
:MMERGE12 => referral['field_6'],
:MMERGE13 => referral['field_7'],
:MMERGE14 => referral['field_8'],
:MMERGE15 => referral['field_9'],
:FNAME => referral['first_name']
}
}
end
#log.info("prepared_batch : #{prepared_batch}")
result = #gibbon.lists.batch_subscribe(
:id => #mc_list_id,
:batch => prepared_batch,
:double_optin => false,
:update_existing => true
)
#log.info("#{result}")
rescue Exception => e
#log.warn("Unable to load batch into mailchimp because #{e.message}")
end
end

Does OpenStruct has support for nesting ? If Yes, How can I construct XML using Nokogiri? If not, Can this be done using Nokogiri and JSon?

The Earlier solution provided by #Jamie seems to be working fine for only few scenario's. The solution is
require 'nokogiri'
require 'ostruct'
xml = <<-'XML'
<Catalog>
<Interface></Interface>
<Dialog></Dialog>
<Manifest></Manifest>
</Catalog>
XML
collection = [
OpenStruct.new(book: '1984', pen: 'George Orwell'),
OpenStruct.new(book: 'Thinking, Fash and Slow', pen: 'Daniel Kahneman')
]
doc = Nokogiri::XML(xml)
catalog = doc.root
node_set = Nokogiri::XML::NodeSet.new(doc)
collection.each do |object|
book = Nokogiri::XML::Node.new('Book', doc)
book_author = Nokogiri::XML::Node.new('Book_Author', doc)
book.content = object.book
book_author.content = object.pen
node_set << book
node_set << book_author
end
catalog.first_element_child.before(node_set)
puts doc.to_xml
While I have the below XML to be constructed using Nokogiri. I just wanted to know, if this can't be done using OpenStruct. Could this be done using Json? If Yes, Can you please suggest me how to construct this using Nokogiri and Json.
Below is this XML, I want to construct...
<CatalogOrder>
<CatalogStoreNumber>657758</CatalogStoreNumber>
<CatalogStoreId>CTH6536</CatalogStoreId>
<CatalogStoreLocation>UnitedStates</CatalogStoreLocation>
<CatalogOwnerId>TYCT11190</CatalogOwnerId>
<CatalogOwner>McGrawHill Pub.</CatalogOwner>
<CatalogList>
<CatalogProductInfo>
<ProductType>Book</ProductType>
<ProductName>The Client</ProductName>
<ProductId>CRSUS113246A</ProductId>
<ProductCategory>Crime And Suspense</ProductCategory>
<ProductSubCategory>Vintage Books</ProductSubCategory>
<ProductPrice>45.50 USD</ProductPrice>
<ProductAuthor>
<AuthorFirstName>John Grisham</AuthorFirstName>
<AuthorMiddleName>Willbur</AuthorMiddleName>
<AuthorContact>19876648981</AuthorContact>
</ProductAuthor>
</CatalogProductInfo>
<CatalogProductInfo>
<ProductType>Pen</ProductType>
<ProductName>Reynolds</ProductName>
<ProductId>PRREY546647</ProductId>
<ProductCategory>Misc. Stationary</ProductCategory>
<ProductSubCategory>Stationary Items</ProductSubCategory>
<ProductPrice>3.00 USD</ProductPrice>
<ProductAuthor>
<AuthorFirstName>Ryan Reynolds</AuthorFirstName>
<AuthorMiddleName>William</AuthorMiddleName>
<AuthorContact>16577589898</AuthorContact>
</ProductAuthor>
</CatalogProductInfo>
<CatalogListType>ProductCollection</CatalogListType>
<CatalogListSource>Web</CatalogListSource>
</CatalogList>
<CatalogVerificationLog>
<CatalogVerificationStatus>Verified</CatalogVerificationStatus>
<CatalogVerificationDateTime>2012-03-12T13:00:15+5:30</CatalogVerificationDateTime>
<CatalogVerificationId>64774A</CatalogVerificationId>
<CatalogVerificationRequestedBy>User_121</CatalogVerificationRequestedBy>
</CatalogVerificationLog>
</CatalogOrder>
I have data that is organized in OpenStruct format below...
require 'ostruct'
require 'nokogiri'
collection = [
OpenStruct.new(:catalogStoreNumber => '657758',
:catalogStoreId => 'CTH6536',
:catalogStoreLocation => 'UnitedStates',
:catalogOwnerId => 'TYCT11190',
:catalogOwner => 'McGrawHill Pub.',
:catalogList => OpenStruct.new(
:catalogProductInfo => OpenStruct.new(
:productType => 'Book',
:productName => 'The Client',
:productId => 'CRSUS113246A',
:productCategory => 'Crime And Suspense',
:productSubcategory => 'Vintage Books',
:productPrice => '45.50 USD',
:productAuthor => OpenStruct.new(
:authorFirstName =>'John Grisham',
:authorMiddleName=> 'Willburt',
:authorContact => '19876648981')),
:catalogProductInfo => OpenStruct.new(
:productType => 'Pen',
:productName => 'Reynolds',
:productId => 'PRREY546647',
:productCategory => 'Misc. Stationary',
:productSubcategory => 'Stationery Items',
:productPrice => '3.00 USD',
:productManufacturer => 'Reynolds Inc.',
:productAuthor => OpenStruct.new(
:authorFirstName => 'Ryan Reynolds',
:authorMiddleName => 'William',
:authorContact => '16577589898')),
:catalogListType => 'ProductCollection',
:catalogListSource => 'Web'
),
:catalogVerificaitionLog => OpenStruct.new(
:catalogVerificationStatus => 'Verified',
:catalogVerificationDateTime => '2012-03-12T13:00:15+5:30',
:catalogVerificationId => '64774A',
:catalogVerificationRequestedBy => 'user_121')
)]
I am not sure whether it is possible with OpenStruct, as it lacks Nesting capabilities. Is there any other Way to use JSon to achieve this without any outstanding limitations ? Please correct my earlier code.
To see this earlier question, How to Add child Nodes in NodeSet using Nokogiri
Click [here] (http://stackoverflow.com/questions/10300095/how-to-add-child-nodes-in-nodeset-using-nokogiri)
I see below issues with OpenStruct...
i want to access the "productType" of first "catalogProductInfo" and i said "collection.catalogList.catalogProductInfo.productType.content" and I get the below error
"undefined method `productType' for # (NoMethodError)
I got stuck here and want to get out if this situation. If data can't be organized using OpenStruct. Can this be done using JSon. ? Also suggest me the way to do it Nokogiri and JSon. Help me out.

Ruby Email Send Undisclosed Recipients

I'm using Ruby to send email via Google apps. The email is being sent and received. The issue is that the email appears in my Gmail inbox as being sent to undisclosed recipients, and with no subject.
require 'rubygems'
require "tlsmail"
message = <<MESSAGE_END
From: From Address <from.address#googleappsdomain.com>
To: My Address <my.address#mydomain.com>
Subject: The Subject
Date: #{Time.now.rfc2822}
This is the email body.
MESSAGE_END
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Net::SMTP.start('smtp.gmail.com', 587, 'smtp.gmail.com', 'from.address#googleappsdomain.com', 'password', :login) do |smtp|
smtp.send_message(message, 'from.address#googleappsdomain.com', 'my.address#mydomain.com')
end
As I noted, the email is received. The headers look like:
from: From Address To: My Address Subject: The Subject Date: Tue, 28 Feb 2012 09:54:22 -0500 from.address#googleappsdomain.com
sender-time: Sent at 9:54 AM (GMT-08:00). Current time there: 7:45 AM. ✆
to:
date: Tue, Feb 28, 2012 at 9:54 AM
With the subject missing.
This is not a huge deal, but I'd like to get it coming in like a typical email if possible.
I don't know if you are firm on using tlsmail, but I have had success with Pony and Google Apps. Here is a modified example of mine:
require 'pony'
email_data = {
:from => 'Mailer <mailer#mydomain.com>',
:to => 'admin#mydomain.com',
:subject => 'Some subject',
:body => 'A plain text body',
:html_body => haml :email, # render html email using haml
:port => '587',
:via => :smtp,
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'mailer#mydomain.com',
:password => 'mailer_password',
:authentication => :plain,
:domain => 'mydomain.com'
}
}
Pony.mail(email_data)
I wrapped this up in a helper (I'm using Sinatra) and pass in specific parameters, merging those with the default options (shown here). I'll update if you'd like to see that as well.

How to geocode a Twitter status update using the Ruby OAuth Gem

Using the following Ruby code, I can send a status update over the Twitter API to my account. According to the Twitter API Docs I would expect it to be geocoded, but it isn't. What am I doing wrong?
require 'oauth'
consumer = OAuth::Consumer.new('<MY_CONSUMER_KEY>', '<MY_CONSUMER_SECRET>', :site => "http://api.twitter.com", :scheme => :header)
access_token = OAuth::AccessToken.from_hash(consumer, :oauth_token => '<MY_OAUTH_TOKEN>', :oauth_token_secret => '<MY_OAUTH_SECRET>')
access_token.request(:post, "http://api.twitter.com/1/statuses/update.xml", {"Content-Type" => "application/xml", "status" => "This Tweet is from Zuerich in Switzerland", "lat" => "47.3807", "long" => "8.537", "display_coordinates" => "true", "geo_enabled" => "true"})
It works ok. You should enable "Add a location to your tweets" in your twitter profile settings.

Resources