Results 1 to 3 of 3

Thread: Photos for Feed Elements (Facebook)

  1. #1
    Join Date
    Mar 2013
    Posts
    3

    Default Photos for Feed Elements (Facebook)

    Hey there,

    i am a bit lost and would be happy if anyone could help me out on this issue:
    My basis is the spring-social-showcase.

    I am trying to display a facebook-look-a-like feed and therefore use the getFeed() method and add it to a model within the controller class.

    Code:
    	@RequestMapping(value="/facebook/feed", method=RequestMethod.GET)
    	public String showFeed(Model model) {
    		model.addAttribute("feed", facebook.feedOperations().getFeed() );
    		return "facebook/feed";
    	}
    I can display all the data properly on the jsp, however i would like to use the thumbnail profile pictures of the users within the displayed feed.

    This is part of the jsp code:

    Code:
    <div id="holder">
    		<c:forEach items="${feed}" var="post">
    			<div class="facebookContain">
    				<div class="facebookPhoto">PHOTO GOES HERE</div>
    				<div class="facebookMainContent">
    					${post.from.name}
    					<div class="facebookComment">${post.message}</div>
    					<div class="facebookControl">TIME · Like · Comment</div>
    
    					<div class="facebookArrow"></div>
    
    					<div class="facebookLikes">
    						<div class="facebookSmallLike"></div>
    						${post.likeCount} like this
    					</div>
    					<c:if test="${not empty post.comments}">
    						<c:forEach items="${post.comments}" var="comments">
    							<div class="facebookSubCommentContainer">
    								<div class="facebookSubCommentPhoto">PHOTO</div>
    								<div class="facebookSubComment">${comments.from.name}
    									${comments.message}</div>
    								<div class="facebookSubCommentControl">TIME · Like</div>
    							</div>
    						</c:forEach>
    					</c:if>
    				</div>
    			</div>
    		</c:forEach>
    	</div>
    I know that application logic should be kept out of the jsp, but now i dont know where to put the logic, that connects the "getFrom()" value to the users Picture i would like to obtain from facebook.mediaOperations().

    My (i guess too simple) idea was to get the ${post.from.id} while iterating within the jsp and somehow use it to call the apropriate function from the mediaOperations() class to retrieve the image url.

    However i have no idea how and where to do it (i guess not in the jsp) but rather in the controller

    Code:
    	@RequestMapping(value="/facebook/feed", method=RequestMethod.GET)
    	public String showFeed(Model model) {
    /*
    do something with the facebook.feedOperations().getFeed() (e.g. iterate), call mediaOperations(), merge to new object and add to model
    */
    
    		model.addAttribute("feed", facebook.feedOperations().getFeed() );
    		return "facebook/feed";
    	}
    I would be glad for any input!

    Thanks in advance

  2. #2
    Join Date
    Aug 2004
    Posts
    1,099

    Default

    For lack of the specific data you need being on the Post object, yes...the best thing to do is retrieve that on the server-side (in your controller) and then do any followup fetching you need to do to get additional data (the image URL in this case). You should avoid doing this in your JSP.

    I agree that this can be cumbersome, especially if you are making many requests to get all you need. Perhaps the bulk operations stuff in the Graph API would be helpful here. At this time, Spring Social's Facebook API doesn't support bulk operations, but that's the subject of https://jira.springsource.org/browse/SOCIALFB-70.
    Craig Walls
    Spring Social Project Lead

  3. #3
    Join Date
    Mar 2013
    Posts
    3

    Default

    Thank you for the input, i did exactly what you proposed and it seems to work.
    Adding bulk operations would be great, so i hope they come in future versions.

    Many thanks for your reply and keep up the great work. I really enjoy using spring social!

Posting Permissions

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