SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Flickr API Response

    Hey,

    I've been having this issue for a while now and need to get it resolved. I am querying the Flickr API and have set my response format to json but when I output the result onscreen via my app, parts of it are escaped. When I run the result through JSON.parse(), it returns valid yaml. How can I convert it to real json? Why isn't the Flickr API returning it in the correct format?

    When I run the call via Flickr's own API testing points on it's site, it shows valid json. So I have no idea what's going wrong.

    My Flickr class:

    Code:
    class Flickr
    
      require 'httparty'
      include HTTParty
    
      API_KEY         = '2e18ffffffaee'
      SECRET          = '88129735hj87y3ci32b2'
      USER_ID         = '5eifenf@9383'
      RESPONSE_FORMAT = 'json'
      base_uri          'http://api.flickr.com'
    
      # Get list of all collections
      def self.collections_list
        response = get("/services/rest/",
          :query => {
            method:          'flickr.collections.getTree',
            api_key:         API_KEY,
            user_id:         USER_ID,
            format:          RESPONSE_FORMAT,
            nojsoncallback:  1
          }
        )
    
        response.body
    
      end
    Any ideas anyone?

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,109
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Try JSON.parse(response.body).to_json where you need to output it in your app


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •