Announcement Announcement Module
No announcement yet.
TwitterTemplate Friendship Functionality Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • TwitterTemplate Friendship Functionality

    Hi All

    Just wondering if there are plans to implement the friendship functionality in the TwitterTemplate. For example friendships/create, friendships/destroy etc.

    Also if I was to start adding that functionality to the TwitterTemplate, should I look into submitting patches back into Spring Social?


  • #2
    See for contribution guidelines. We recently received a merge request for additions to FacebookTemplate and are reviewing that for integration as we speak.



    • #3
      Started Work on the Follow/Unfollow Functionality

      Hi Guys

      So I'm working on the follow/unfollow functionality and am currently in the middle of testing the code. I used the apigee console to simulate a follow POST as follows:

      and received the following response

      "favourites_count" : 0,
      "friends_count" : 2,
      "profile_background_color" : "C0DEED",
      "url" : null,
      "profile_background_image_url" : "",
      "description" : null,
      "screen_name" : "oizik2",
      "status": {
      "in_reply_to_status_id_str" : null,
      "in_reply_to_user_id" : null,
      "text" : "woohoo my twitter application is still working!!! ",
      "contributors" : null,
      "retweeted" : false,
      "in_reply_to_user_id_str" : null,
      "retweet_count" : 0,
      "geo" : null,
      "source" : <a href='' rel='nofollow'>iPeg - Test</a>,
      "created_at" : "Tue Feb 01 09:35:27 +0000 2011",
      "id_str" : "32371442398007296",
      "place" : null,
      "in_reply_to_status_id" : null,
      "coordinates" : null,
      "truncated" : false,
      "favorited" : false,
      "id" : 32371442398007296,
      "in_reply_to_screen_name" : null
      "verified" : false,
      "location" : null,
      "listed_count" : 0,
      "time_zone" : null,
      "profile_text_color" : "333333",
      "lang" : "en",
      "notifications" : false,
      "created_at" : "Fri Jan 14 08:00:25 +0000 2011",
      "profile_sidebar_fill_color" : "DDEEF6",
      "id_str" : "238061111",
      "show_all_inline_media" : false,
      "geo_enabled" : false,
      "profile_background_tile" : false,
      "followers_count" : 1,
      "profile_link_color" : "0084B4",
      "protected" : false,
      "statuses_count" : 7,
      "profile_sidebar_border_color" : "C0DEED",
      "name" : "Gary Jarrel",
      "is_translator" : false,
      "contributors_enabled" : false,
      "following" : true,
      "id" : 238061111,
      "follow_request_sent" : false,
      "profile_use_background_image" : true,
      "utc_offset" : null,
      "profile_image_url" : ""

      This is one of my Twitter testing accounts.

      I then used the entire response in the follow.json file which and subsequently used it in my test case with the mockServer ... andRespond(withResponse(new ClassPathResource("follow.json", getClass()), responseHeaders));

      The problem is effectively with the returned JSON data and the line "source" : <a href='' rel='nofollow'>iPeg - Test</a>, notice how the URL is not quoted and this cause Jackson to fail with the following exception

      org.springframework.http.converter.HttpMessageNotR eadableException: Could not read JSON: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
      at [Source: [email protected]; line: 18, column: 17]; nested exception is org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
      at [Source: [email protected]; line: 18, column: 17]
      at org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter.readInternal(MappingJacks
      at org.springframework.http.converter.AbstractHttpMes va:154)
      at org.springframework.web.client.HttpMessageConverte rExtractor.extractData(HttpMessageConverterExtract
      at org.springframework.web.client.RestTemplate$Respon seEntityResponseExtractor.extractData(RestTemplate .java:619)
      at org.springframework.web.client.RestTemplate$Respon seEntityResponseExtractor.extractData(RestTemplate .java:1)
      at org.springframework.web.client.RestTemplate.doExec ute(
      at org.springframework.web.client.RestTemplate.execut e(
      at org.springframework.web.client.RestTemplate.postFo rEntity(
      at .follow(
      at Test.follow(

      When I manually put the quotes around the URL then it works fine, however with the actual Twitter response it fails on the < character.

      Is there a way to tell Jackson to treat this as a String perhaps, or add an exception to allow parsing such data?

      Or perhaps I should go to the Jackson mailing list?




      • #4

        Please ignore my post above, I was using the response from apigee console, when I used the Twurl console the response was formatted correctly.