Skip to content

Changing User Agent String

hayesdavis edited this page Sep 13, 2010 · 2 revisions

It’s often a good idea to set a custom User-Agent header when communicating with the Twitter API, especially when using the Search API. By default, Grackle sends the following User-Agent header:

Grackle/VERSION

(Where VERSION is the version of the Grackle gem you have installed. e.g. 0.1.6. This comes from Grackle::VERSION.)

Changing the User-Agent string helps uniquely identify your application to Twitter, which helps with support requests. You can change your User-Agent string in two ways:

When you instantiate a new client:
client = Grackle::Client.new(:headers => {'User-Agent' => "MyApp/#{VERSION} Grackle/#{Grackle::VERSION}"})

Dynamically:
client.headers['User-Agent'] = "MyApp/#{VERSION} Grackle/#{Grackle::VERSION}"

In the above examples we’re specifying both the version of the application we’re writing, as well as the version of the Grackle library.

Clone this wiki locally