Module: Twitter::API::Trends

Includes:
Utils
Included in:
Client
Defined in:
lib/twitter/api/trends.rb

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Instance Method Details

Returns the top 10 trending topics for a specific WOEID

Examples:

Return the top 10 trending topics for San Francisco

Twitter.trends(2487956)

Parameters:

  • id (Integer) (defaults to: 1)

    The Yahoo! Where On Earth ID of the location to return trending information for. WOEIDs can be retrieved by calling #trend_locations. Global information is available by using 1 as the WOEID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :exclude (String)

    Setting this equal to 'hashtags' will remove all hashtags from the trends list.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



22
23
24
25
26
# File 'lib/twitter/api/trends.rb', line 22

def trends(id=1, options={})
  options[:id] = id
  response = get("/1.1/trends/place.json", options)
  objects_from_array(Twitter::Trend, response[:body].first[:trends])
end

Returns the locations that Twitter has trending topic information for

Examples:

Return the locations that Twitter has trending topic information for

Twitter.trends_available

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



40
41
42
# File 'lib/twitter/api/trends.rb', line 40

def trends_available(options={})
  objects_from_response(Twitter::Place, :get, "/1.1/trends/available.json", options)
end

Returns the locations that Twitter has trending topic information for, closest to a specified location.

Examples:

Return the locations that Twitter has trending topic information for

Twitter.trends_closest

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :lat (Float)

    If provided with a :long option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for latitude are -90.0 to +90.0 (North is positive) inclusive.

  • :long (Float)

    If provided with a :lat option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



57
58
59
# File 'lib/twitter/api/trends.rb', line 57

def trends_closest(options={})
  objects_from_response(Twitter::Place, :get, "/1.1/trends/closest.json", options)
end