それを理解し、名前付きクエリも使用しました:
Callingメソッドと結果を処理します。
public List<FacebookMovie> GetMoviesLikedByFriends()
{
string strQuery0 = "SELECT page_id, uid FROM page_fan WHERE type='MOVIE' AND uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY page_id";
string strQuery1 = "SELECT page_id, name, pic, page_url, fan_count, genre, starring, release_date FROM page WHERE page_id IN (SELECT page_id FROM #friendsMovies) ORDER BY page_id";
Dictionary<string, object> dicQuery = new Dictionary<string, object>();
dicQuery.Add("friendsMovies", strQuery0);
dicQuery.Add("movies", strQuery1);
FacebookSDKInterface objFQL = new FacebookSDKInterface();
dynamic objMoviesFriendsLike = objFQL.FBMFQL(dicQuery);
//To access a direct value: resultsMQFQL.data[0].fql_result_set[0].page_id
if (objMoviesFriendsLike != null) // shouldn't you check objFNU for being null here instead?
{
IEnumerable<dynamic> friendsMovies = (IEnumerable<dynamic>)objMoviesFriendsLike.data[0].fql_result_set; // explicit cast might not be necessary
IEnumerable<dynamic> movieDetails = (IEnumerable<dynamic>)objMoviesFriendsLike.data[1].fql_result_set; // explicit cast might not be necessary
IEnumerable<FacebookMovie> objMyFriendsMovies =
from Movie in movieDetails
join FriendsMovies in friendsMovies on (string)Movie.page_id equals (string)FriendsMovies.page_id
group FriendsMovies by new
{
ID = Movie.movie_id,
Link = Movie.page_url,
MovieName = Movie.name,
TotalLikes = Movie.fan_count,
Genre = Movie.genre,
Starring = Movie.starring,
ReleaseDate = Movie.release_date,
PicURL = Movie.pic
} into grp
where grp.Count() >= 2 //at least 2 friends must have liked it to show up
select new FacebookMovie()
{
Source = "Facebook",
ID = (string)grp.Key.ID,
SourceURL = (string)grp.Key.Link,
Name = (string)grp.Key.MovieName,
Picture = (string)grp.Key.PicURL,
TotalLikes = (long)grp.Key.TotalLikes,
Genre = (string)grp.Key.Genre,
Starring = (string)grp.Key.Starring,
ReleaseDate = (string)grp.Key.ReleaseDate,
FriendLikes = (int)grp.Count()
};
objMyFriendsMovies = objMyFriendsMovies.OrderByDescending(p => p.FriendLikes);
return objMyFriendsMovies.ToList();
}
else
{
return new List<FacebookMovie>();
}
}
クエリを実行する方法:
public dynamic FBMFQL(Dictionary<string, object> dicQuery)
{
try
{
var fb = new FacebookClient(this.FacebookAccessToken);
dynamic objFQL = fb.Get("fql", new { q = dicQuery });
if (objFQL == null)
{
return null;
}
else
{
return objFQL;
}
}
catch (FacebookApiException ex)
{
FacebookErrorHandler(ex);
return null;
}
} //FB FQL