Video thumbnail_url

37 views
Skip to first unread message

Humppakäräjät

unread,
May 21, 2010, 11:01:32 AM5/21/10
to RestFB
Hi,

I'm trying to get the thumbnail url and the title of a video.

This is my code:

FacebookClient facebookClient = new
DefaultFacebookClient("XXXXXXXXXXX...XXXXXXXXXX");
String query = "SELECT vid, thumbnail_link, title, description FROM
video WHERE vid=238358730483";
List<Video> videos = facebookClient.executeQuery(query, Video.class);

The code works without errors. But the resulting Video object only has
the description stored as an member.
The thumbnail url and title are missing. According to the RestFB
javadoc the Video class does not contain a implementation for
thumbnail_link and title.

So, how do I get the title and thumbnail_link for the video, using the
RestFB library?
Maybe there is a way to get the raw API response data?


Thank you
Humppakäräjät

PS: sorry for my silly english

revetkn

unread,
May 21, 2010, 11:14:12 AM5/21/10
to RestFB
Your English is just fine! :)

For FQL queries, you'll want to write your own class since RestFB
can't know ahead of time what columns you'll be asking for. Example:

public class MyVideo {
@Facebook
private String vid;

@Facebook
private String title;

@Facebook("thumbnail_url")
private String thumbnailUrl;

...

public String getVid() {
return vid;
}

public String getTitle() {
return title;
}

public String getThumbnailUrl {
return thumbnailUrl;
}

...
}

...

List<MyVideo> videos = facebookClient.executeQuery(query,
MyVideo.class);

The built-in types in com.restfb.types are mappings to Graph API
objects, not FQL resultsets. See here: http://developers.facebook.com/docs/reference/api/

You are free to extend them yourself or write your own replacements as
the situation dictates.

Thanks for using RestFB
Mark

Humppakäräjät

unread,
May 21, 2010, 12:52:27 PM5/21/10
to RestFB
Hi revetkn,

thank you for your help. I followed your example and it works now.
Here is the Video class I wrote, maybe some one else will find it
helpful:


package sl.webvideo.Templates;

import com.restfb.Facebook;
import com.restfb.types.Video;

public class FacebookVideo extends Video
{
@Facebook
private String vid;

@Facebook
private String title;

@Facebook("thumbnail_link")
private String thumbnailUrl;


public String getVid()
{
return vid;
}

public void setVid(String vid)
{
this.vid = vid;
}

public String getTitle()
{
return title;
}

public void setTitle(String title)
{
this.title = title;
}

public String getThumbnailUrl()
{
return thumbnailUrl;
}

public void setThumbnailUrl(String thumbnailUrl)
{
this.thumbnailUrl = thumbnailUrl;
Reply all
Reply to author
Forward
0 new messages