本文整理汇总了C#中Facebook.FacebookClient.QueryAsync方法的典型用法代码示例。如果您正苦于以下问题:C# FacebookClient.QueryAsync方法的具体用法?C# FacebookClient.QueryAsync怎么用?C# FacebookClient.QueryAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook.FacebookClient
的用法示例。
在下文中一共展示了FacebookClient.QueryAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnGetFriendsList_Click
private void btnGetFriendsList_Click(object sender, RoutedEventArgs e)
{
FacebookClient client = new FacebookClient(Token());
string fqlFriendsList = "SELECT uid2 FROM friend where uid1=me()";
client.GetCompleted += new EventHandler<FacebookApiEventArgs>(client_GetCompleted);
client.QueryAsync(fqlFriendsList, Token());
}
示例2: Run
public void Run()
{
//1. Prepare API
string fqlQuery = "SELECT uid, name, pic_big, pic_square, profile_url " +
"FROM user WHERE uid=" + userUid.ToString();
//2. Add Async Event Handler
FacebookClient client = new FacebookClient(fbToken);
client.GetCompleted += new EventHandler<FacebookApiEventArgs>(client_GetCompleted);
//3. Execute
client.QueryAsync(fqlQuery);
}
示例3: FqlMultiQueryAsyncExample
private void FqlMultiQueryAsyncExample()
{
var fb = new FacebookClient(_accessToken);
// since FQL multi-query is internally a GET request,
// make sure to add the GET event handler.
fb.GetCompleted += (o, e) =>
{
// incase you support cancellation, make sure to check
// e.Cancelled property first even before checking (e.Error!=null).
if (e.Cancelled)
{
// for this example, we can ignore as we don't allow this
// example to be cancelled.
// you can check e.Error for reasons behind the cancellation.
var cancellationError = e.Error;
}
else if (e.Error != null)
{
// error occurred
this.BeginInvoke(new MethodInvoker(
() =>
{
//MessageBox.Show(e.Error.Message);
}));
}
else
{
// the request was completed successfully
// now we can either cast it to IDictionary<string, object> or IList<object>
// depending on the type. or we could use dynamic.
dynamic result = e.GetResultData();
dynamic resultForQuery1 = result[0].fql_result_set;
dynamic resultForQuery2 = result[1].fql_result_set;
var uid = resultForQuery1[0].uid;
this.BeginInvoke(new MethodInvoker(
() =>
{
// make sure to be on the right thread when working with ui.
}));
}
};
var query1 = "SELECT uid FROM user WHERE uid=me()";
var query2 = "SELECT profile_url FROM user WHERE uid=me()";
// call the Query or QueryAsync method to execute a single fql query.
// if there is more than one query Query/QueryAsync method will automatically
// treat it as multi-query.
fb.QueryAsync(new[] { query1, query2 });
}
示例4: FqlAsyncExample
private void FqlAsyncExample()
{
var fb = new FacebookClient(_accessToken);
// since FQL is internally a GET request,
// make sure to add the GET event handler.
fb.GetCompleted += (o, e) =>
{
// incase you support cancellation, make sure to check
// e.Cancelled property first even before checking (e.Error!=null).
if (e.Cancelled)
{
// for this example, we can ignore as we don't allow this
// example to be cancelled.
// you can check e.Error for reasons behind the cancellation.
var cancellationError = e.Error;
}
else if (e.Error != null)
{
// error occurred
this.BeginInvoke(new MethodInvoker(
() =>
{
//MessageBox.Show(e.Error.Message);
}));
}
else
{
// the request was completed successfully
// now we can either cast it to IDictionary<string, object> or IList<object>
// depending on the type. or we could use dynamic.
var result = (IList<object>)e.GetResultData();
var count = result.Count;
// since this is an async callback, make sure to be on the right thread
// when working with the UI.
this.BeginInvoke(new MethodInvoker(
() =>
{
lblTotalFriends.Text = string.Format("You have {0} friend(s).", count);
}));
}
};
// query to get all the friends
var query = string.Format("SELECT uid,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})", "me()");
// call the Query or QueryAsync method to execute a single fql query.
fb.QueryAsync(query);
}
示例5: Run
public void Run()
{
//1. Prepare API
string query0 = "SELECT uid2 FROM friend where uid1=me()";
string query1 =
"SELECT uid, name, pic_big ,pic_square, profile_url, profile_update_time, is_app_user, wall_count, " +
"birthday_date, online_presence, relationship_status, significant_other_id, sex, status, website " +
"FROM user WHERE uid IN (SELECT uid2 FROM #query0)";
string query2 = "SELECT uid,time,message FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1= me())";
string[] fqlMultiQuery = { query0, query1, query2 };
//2. Add Async Event Handler
FacebookClient client = new FacebookClient(fbToken);
client.GetCompleted += new EventHandler<FacebookApiEventArgs>(client_GetCompleted);
//3. Execute
client.QueryAsync(fqlMultiQuery);
}