本文整理汇总了C#中Facebook.FacebookClient.GetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# FacebookClient.GetAsync方法的具体用法?C# FacebookClient.GetAsync怎么用?C# FacebookClient.GetAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook.FacebookClient
的用法示例。
在下文中一共展示了FacebookClient.GetAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFriendsCount
private object GetFriendsCount()
{
var fb = new FacebookClient(txtAccessToken.Text);
//var fb = new FacebookClient();
for (int i = 0; i < 100; i++) {
dynamic result1 = fb.Get(i);
string id = result1.id;
string firstName = result1.first_name;
var lastName = result1.last_name;
}
var query = string.Format("SELECT friend_count, name FROM user WHERE uid = me()");
// var query1 = string.Format("SELECT uid,name,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})", "me()");
fb.GetAsync("fql", new { q = query });
object returnVal = 0;
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
// Dispatcher.BeginInvoke();// () => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
var data = (IList<object>)result["data"];
foreach (var comment in data.Cast<IDictionary<string, object>>())
{
returnVal = comment["friend_count"];
// Dispatcher.BeginInvoke(() => MessageBox.Show(returnVal.ToString()));
}
};
return returnVal;
}
示例2: MyProfile
// My facebook feed.
internal void MyProfile()
{
GlobalContext.g_UserProfile = new UserProfile();
var fb = new FacebookClient(GlobalContext.AccessToken);
fb.GetCompleted +=
(o, ex) =>
{
try
{
var feed = (IDictionary<String, object>)ex.GetResultData();
GlobalContext.g_UserProfile.Name = feed["name"].ToString();
GlobalContext.g_UserProfile.UserID = feed["id"].ToString();
GlobalContext.g_UserProfile.Picture = (String)((IDictionary<String, object>)((IDictionary<String, object>)feed["picture"])["data"])["url"];
// GlobalContext.g_UserProfile.Picture = picture.data.url;
DBManager.getInstance().saveData(DBManager.DB_Profile, GlobalContext.g_UserProfile);
Deployment.Current.Dispatcher.BeginInvoke(delegate(){
App42Api.LinkUserFacebookAccount(LinkUserFacebookCallback);
});
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
};
var parameters = new Dictionary<String, object>();
parameters["fields"] = "id,name,picture";
fb.GetAsync("me", parameters);
}
示例3: LoadUserInfo
/// <summary>
/// Loads the user info.
/// </summary>
private void LoadUserInfo()
{
var fb = new FacebookClient(App.AccessToken);
fb.GetCompleted += (sender, args) =>
{
if (args.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
return;
}
var result = args.GetResultData<IDictionary<string, object>>();
Dispatcher.BeginInvoke(() =>
{
FacebookData.Me.Name = String.Format(
"{0} {1}",
(string)result["first_name"],
(string)result["last_name"]);
FacebookData.Me.PictureUri = new Uri(String.Format(
"https://graph.facebook.com/{0}/picture?type={1}&access_token={2}",
App.FacebookId,
"square",
App.AccessToken));
});
fb.GetAsync("me");
};
}
示例4: LoginSucceded
private void LoginSucceded(string accessToken)
{
var fb = new FacebookClient(accessToken);
var are = new AutoResetEvent(false);
Dispatcher.BeginInvoke(() => {
NavigationService.Navigate(new Uri("/Connecting.xaml", UriKind.Relative));
are.Set();
});
fb.GetCompleted += (o, e) => {
if (e.Error != null) {
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
var id = (string)result["id"];
Connection.FacebookUid = id;
Connection.LoginType = 1;
are.WaitOne();
Dispatcher.BeginInvoke(() => Connection.Connect((Page) ((PhoneApplicationFrame)Application.Current.RootVisual).Content));
};
fb.GetAsync("me?fields=id");
}
示例5: LoadUserInfo
private void LoadUserInfo()
{
var fb = new FacebookClient(App.AccessToken);
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
Dispatcher.BeginInvoke(() =>
{
//ProfileName.Text = "Hi " + (string)result["name"];
string myName = String.Format("{0} {1}", (string)result["first_name"], (string)result["last_name"]);
Uri myPictureUri = new Uri(string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", App.FacebookId, "square", App.AccessToken));
this.MyImage.Source = new BitmapImage(myPictureUri);
this.MyName.Text = myName;
});
};
fb.GetAsync("me");
}
示例6: GetEventsList
public void GetEventsList()
{
string fetchStr = string.Format(FetchString, ID);
RFBClient = new FacebookClient(FBAuthenticationService.AccessToken);
RFBClient.GetCompleted += new EventHandler<FacebookApiEventArgs>(OnGetEventsCompleted);
RFBClient.GetAsync(fetchStr);
}
示例7: myProfile
// My facebook feed.
public void myProfile()
{
var fb = new FacebookClient(_accessToken);
fb.GetCompleted +=
(o, ex) =>
{
var feed = (IDictionary<string, object>)ex.GetResultData();
var me = feed["picture"] as JsonObject;
var pic = me["data"] as JsonObject;
string picture = pic["url"].ToString();
string name = feed["name"].ToString();
string id = feed["id"].ToString();
UpdateProfile(name, id, picture);
};
var parameters = new Dictionary<string, object>();
parameters["fields"] = "id,name,picture";
fb.GetAsync("me", parameters);
}
示例8: ProcessFbOathResult
public bool ProcessFbOathResult(FacebookOAuthResult oauthResult)
{
var resultProcess = false;
var accessToken = oauthResult.AccessToken;
App.ViewModel.UserPreference.AccessKey = accessToken;
var fbS = new FacebookClient(accessToken);
fbS.GetCompleted += (o, res) =>
{
if (res.Error != null)
{
Dispatcher.BeginInvoke(() =>
{
gridFBLoggedIn.Visibility =
Visibility.Collapsed;
FaceBookLoginPage.Visibility =
Visibility.Collapsed;
LinkButton.Visibility = Visibility.Visible;
});
return;
}
var result = (IDictionary<string, object>) res.GetResultData();
App.ViewModel.UserPreference.FbUserId = (string) result["id"];
App.ViewModel.UserPreference.Name = (string) result["name"];
App.ViewModel.LoadData(true);
App.ViewModel.SaveSettings();
Dispatcher.BeginInvoke(() =>
{
facebookImage.Source =
App.ViewModel.UserPreference.UserImage;
name.Text = App.ViewModel.UserPreference.Name;
});
resultProcess = true;
};
fbS.GetAsync("me");
return resultProcess;
}
示例9: FriendImages
public List<string> FriendImages(ActivityItemsViewModel act)
{
if (App.ViewModel.UserPreference.AccessKey == null || act.FacebookId == null || act.FacebookId.Equals("") || !App.ViewModel.HasConnection)
return null;
var friends = new List<string>();
var fb = new FacebookClient
{
AppId = App.ViewModel.Appid,
AccessToken = App.ViewModel.UserPreference.AccessKey
};
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
var data = (IList<object>)result["data"];
if (data.Count <= 0)
{
return;
}
act.FriendsAttending = data.Count;
for (var i = 0; i < 5; i++)
{
var eventData = ((IDictionary<string, object>)data.ElementAt(i));
friends.Add((string)eventData["pic_square"]);
}
};
var query = String.Format("SELECT pic_square FROM user WHERE uid IN"
+ "(SELECT uid2 FROM friend WHERE uid1 = me() AND uid2 IN"
+ "(SELECT uid FROM event_member WHERE eid = {0} "
+ "AND rsvp_status = 'attending'))", act.FacebookId);
fb.GetAsync("fql", new { q = query });
return friends;
}
示例10: LoginSucceded
private void LoginSucceded(string accessToken)
{
var fb = new FacebookClient(accessToken);
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
SettingsManager.FacebookActive = true;
SettingsManager.FacebookToken = accessToken;
SettingsManager.FacebookId = (string)result["id"];
Dispatcher.BeginInvoke(() => {
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
});
};
fb.GetAsync("me?fields=id");
}
示例11: LoadUserInfo
private void LoadUserInfo()
{
var fb = new FacebookClient(fftoken);
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
Dispatcher.BeginInvoke(() =>
{
var profilePictureUrl = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}&width=150&height=150", ffid, "square", fftoken);
this.user_image.Source = new BitmapImage(new Uri(profilePictureUrl));
//this.MyName.Text = String.Format("{0} {1}", (string)result["first_name"], (string)result["last_name"]);
});
};
fb.GetAsync("me");
}
示例12: 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 = (IDictionary<string, object>)e.GetResultData();
var data = (IList<object>)result["data"];
var count = data.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.GetAsync("fql", new { q = query });
}
示例13: FqlSample
/// <summary>
/// Fql Sample to get Result
/// </summary>
public void FqlSample()
{
var fb = new FacebookClient(_accessToken);
fb.GetCompleted += (o, args) =>
{
if (args.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
return;
}
var result = (IDictionary<string, object>) args.GetResultData();
var data = (IList<object>) result["data"];
// since this is an async callback, make sure to be on the right thread
// when working with the UI.
Dispatcher.BeginInvoke(() =>
{
txtAnswer.Text = data.ToString();
});
};
// 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()");
fb.GetAsync("fql", new {q = query});
}
示例14: LoadUserInformation
/// <summary>
/// Load Facebook information of the user
/// </summary>
public void LoadUserInformation()
{
// available picture types: square (50x50), small (50xvariable height), large (about 200x variable height) (all size in pixels)
string profilePictureUrl = string.Format(
"https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", _userId, "square", _accessToken);
// load profile picture
picProfile.Source = new BitmapImage(new Uri(profilePictureUrl));
var fb = new FacebookClient(_accessToken);
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>) e.GetResultData();
Dispatcher.BeginInvoke(() =>
{
ProfileName.Text = "Hi " + (string) result["name"];
FirstName.Text = "First Name: " +
(string) result["first_name"];
FirstName.Text = "Last Name: " +
(string) result["last_name"];
});
};
// get user information
fb.GetAsync("me");
}
示例15: GetComments
private void GetComments(String photoID,String URL)
{
String comments = "";
var fb = new FacebookClient(_accessToken);
fb.GetCompleted += (o, e) =>
{
if (e.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
return;
}
var result = (IDictionary<string, object>)e.GetResultData();
Dispatcher.BeginInvoke(() =>
{
int min=2;
IList data = (IList)result["data"];
if (data.Count < 2)
min = data.Count;
for (int i = 0; i < min; i++)
{
IDictionary<string, object> entry = (IDictionary<string, object>)data[i];
IDictionary<string, object> from = (IDictionary<string, object>)entry["from"];
comments = comments + (string)from["name"] + ": ";
comments = comments + (string)entry["message"]+ " ";
}
if (comments == "")
comments = "No comments. Tap to open in facebook and comment there.";
HubTile hubtile = (HubTile)this.FindName(URL);
hubtile.Message = comments;
});
};
fb.GetAsync(photoID + "/comments?limit=2&fields=from,message");
}