Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook API updated to v2.5 #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Facebook C# SDK for Windows & Windows Phone
The Facebook C# SDK for Windows & Windows Phone helps .NET developers build Windows Phone and Windows Store applications that integrate with Facebook.

branch APIv2.5 uses Facebook API v2.5

[Like us on Facebook at our official page](http://facebook.com/csharpsdk) or [Follow us on twitter @chsarpsdk](http://twitter.com/csharpsdk).

## NuGet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ public void ShowAppRequestsDialog(WebDialogFinishedDelegate callback, string mes
#endif

#if WINDOWS_PHONE
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&message={3}&display=touch{4}&title={5}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.AppId, message, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title)));
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.5/dialog/apprequests?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&message={3}&display=touch{4}&title={5}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.AppId, message, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title)));
#endif

#if WP8

dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&message={2}&display=touch{3}&title={4}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, message, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title)));
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.5/dialog/apprequests?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&message={2}&display=touch{3}&title={4}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, message, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title)));
#endif
}

Expand All @@ -204,12 +204,12 @@ internal static void ShowAppRequestDialogViaBrowser(string message, string title
}
}

Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/apprequests?access_token={0}&redirect_uri={2}&app_id={1}&message={5}&display=touch{3}&title={4}&data={6}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.AppRequestRedirectUri, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title, message, data)));
Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.5/dialog/apprequests?access_token={0}&redirect_uri={2}&app_id={1}&message={5}&display=touch{3}&title={4}&data={6}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.AppRequestRedirectUri, idBuilder.Length > 4 ? idBuilder.ToString() : String.Empty, title, message, data)));
}

internal static void ShowFeedDialogViaBrowser(string toId = "", string link = "", string linkName = "", string linkCaption = "", string linkDescription = "", string picture = "")
{
Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri={2}&app_id={1}&display=touch&to={3}&link={4}&name={5}&caption={6}&description={7}&picture={8}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.FeedRedirectUri, toId, link, linkName, linkCaption, linkDescription, picture)));
Launcher.LaunchUriAsync(new Uri(String.Format("https://m.facebook.com/v2.5/dialog/feed?access_token={0}&redirect_uri={2}&app_id={1}&display=touch&to={3}&link={4}&name={5}&caption={6}&description={7}&picture={8}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.FeedRedirectUri, toId, link, linkName, linkCaption, linkDescription, picture)));
}


Expand All @@ -225,11 +225,11 @@ public void ShowFeedDialog(string toId = "", string link = "", string linkName =
#endif

#if WP8
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&display=touch&to={2}&link={3}&name={4}&caption={5}&description={6}&picture={7}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, toId, link, linkName, linkCaption, linkDescription, picture)));
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.5/dialog/feed?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&display=touch&to={2}&link={3}&name={4}&caption={5}&description={6}&picture={7}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, toId, link, linkName, linkCaption, linkDescription, picture)));
#endif

#if WINDOWS_PHONE
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.1/dialog/feed?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&display=touch&to={3}&link={4}&name={5}&caption={6}&description={7}&picture={8}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.AppId, toId, link, linkName, linkCaption, linkDescription, picture)));
dialogWebBrowser.Navigate(new Uri(String.Format("https://m.facebook.com/v2.5/dialog/feed?access_token={0}&redirect_uri=fb{2}%3A%2F%2Fsuccess&app_id={1}&display=touch&to={3}&link={4}&name={5}&caption={6}&description={7}&picture={8}", Session.ActiveSession.CurrentAccessTokenData.AccessToken, Session.AppId, Session.AppId, toId, link, linkName, linkCaption, linkDescription, picture)));

#endif

Expand Down
2 changes: 1 addition & 1 deletion Source/Facebook.Client/FacebookAppLinkResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async public Task<AppLink> GetAppLinkAsync(string accessToken, string sourceUrl)
{
FacebookClient _client = new FacebookClient(accessToken);

String finalUrl = String.Format("https://graph.facebook.com/v2.0/?ids={0}&type=al&fields=windows,windows_phone,windows_universal", sourceUrl);
String finalUrl = String.Format("https://graph.facebook.com/v2.5/?ids={0}&type=al&fields=windows,windows_phone,windows_universal", sourceUrl);
dynamic appLinkData = await _client.GetTaskAsync(finalUrl);
List<Target> targets = new List<Target>();

Expand Down
6 changes: 3 additions & 3 deletions Source/Facebook.Client/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ async public void LoginWithBehavior(string permissions, FacebookLoginBehavior be
Uri uri =
new Uri(
String.Format(
"https://m.facebook.com/v2.1/dialog/oauth?redirect_uri={0}&display=touch&state=%7B%220is_active_session%22%3A1%2C%22is_open_session%22%3A1%2C%22com.facebook.sdk_client_state%22%3A1%2C%223_method%22%3A%22browser_auth%22%7D&scope={2}&type=user_agent&client_id={1}&sdk=ios",
"https://m.facebook.com/v2.5/dialog/oauth?redirect_uri={0}&display=touch&state=%7B%220is_active_session%22%3A1%2C%22is_open_session%22%3A1%2C%22com.facebook.sdk_client_state%22%3A1%2C%223_method%22%3A%22browser_auth%22%7D&scope={2}&type=user_agent&client_id={1}&sdk=ios",
LoginRedirectUri, appId, permissions), UriKind.Absolute);

Launcher.LaunchUriAsync(uri);
Expand All @@ -498,7 +498,7 @@ async public void LoginWithBehavior(string permissions, FacebookLoginBehavior be
Uri uri =
new Uri(
String.Format(
"https://m.facebook.com/v2.1/dialog/oauth?redirect_uri={0}%3A%2F%2Fauthorize&display=touch&state=%7B%220is_active_session%22%3A1%2C%22is_open_session%22%3A1%2C%22com.facebook.sdk_client_state%22%3A1%2C%223_method%22%3A%22browser_auth%22%7D&scope={2}&type=user_agent&client_id={1}&sdk=ios",
"https://m.facebook.com/v2.5/dialog/oauth?redirect_uri={0}%3A%2F%2Fauthorize&display=touch&state=%7B%220is_active_session%22%3A1%2C%22is_open_session%22%3A1%2C%22com.facebook.sdk_client_state%22%3A1%2C%223_method%22%3A%22browser_auth%22%7D&scope={2}&type=user_agent&client_id={1}&sdk=ios",
String.Format("fb{0}", appId), appId, permissions), UriKind.Absolute);
#else
Uri uri = await GetLoginUrl(permissions);
Expand Down Expand Up @@ -573,7 +573,7 @@ public async static Task CheckAndExtendTokenIfNeeded()
if (DateTime.UtcNow - ActiveSession.CurrentAccessTokenData.Issued > TimeSpan.FromHours(24)) // one day
{
var client = new HttpClient();
String tokenExtendUri = "https://graph.facebook.com/v2.1";
String tokenExtendUri = "https://graph.facebook.com/v2.5";
client.BaseAddress = new Uri(tokenExtendUri);

var request = new HttpRequestMessage();
Expand Down