GithubHelp home page GithubHelp logo

facebook-windows-phone-sample's Introduction

Facebook C# SDK Sample with Windows Phone 7

This sample demonstrates the use of Facebook C# SDK v6 as a Windows Phone 7 Application.

Note: This sample does not necessarily demonstrate the best use but rather features of using Facebook C# SDK on a Windows Phone 7 app. Always remember to handle exceptions.

Getting started

Set the appropriate AppId in FacebookLoginPage.xaml.cs before running the sample.

private const string AppId = "app_id";

Note:

  • For new projects using Facebook C# SDK which use anonymous objects as parameters make sure to add [assembly: InternalsVisibleTo("Facebook")] in AssemblyInfo.cs.
  • When updating UI in callback make sure to execute it in the appropriate thread. This can be solved by using Dispatcher.Invoke() method.
  • Create new instance of FacebookClient for each XAsync method calls in order to avoid the event handler from being fired multiple times.

facebook-windows-phone-sample's People

Contributors

prabirshrestha avatar sanjeevdwivedi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facebook-windows-phone-sample's Issues

certificate error

hi,

when i start the sample projects i always get a certificate error:
certificateerror
how to fix this problem?
cheers

Back navigation

If you hit the button "Login To Facebook" then the page with the facebook login UI loads.
Then when i hit the back button on my phone i get a black screen and a error message then when i hit back again i'm seeing the MainPage.xaml. Now the "Login To Facebook" button does not show the login UI but gives a direct error message.

Not Implemented Exception thrown when using Windows phone 8.1 SDK

I am working through the samples for login on the facebooksdk.net site and have the sample for login working for a Windows store app working as expected.

I cannot get the sample for a Windows Phone app to work properly, however. When I follow the sample, I have to first modify the XAML namespace sample from: xmlns:facebookControls="clr-namespace:Facebook.Client.Controls;assembly=Facebook.Client" to xmlns:facebookControls="using:Facebook.Client.Controls". This is the same as it is for the Windows Store application and prevents a compilation error in VS 2013 from occurring. Even after doing this, I do NOT see the login button appear in the designer as I do for the Windows app. At runtime the button does appear in the emulator or on a device. When clicking the Facebook login button a “Not Implemented Exception” is thrown from deep in the stack which appears to be coming from Facebook.Client.FacebookSessionClient as can be seen in this stack trace:

at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
at Facebook.Client.FacebookSessionClient.d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Facebook.Client.FacebookSessionClient.<LoginAsync>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Facebook.Client.FacebookSessionClient.d__e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Facebook.Client.Controls.LoginButton.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Facebook.Client.Controls.LoginButton.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.b__3(Object state)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()

I am wondering if this is something that is known and if there is a work around for this issue? Here are the versions of the NuGet packages that I am currently using:
Facebook: 6.0.10.0
Facebook.Client: 0.9.1.0
Visual Studio 2013 R3 with .NET 4.5.1

This property is not implemented by this class. Error in my project.

I am following Your Instructions. It was working in my sample project. When i try to implement in my original project i get error.

private void LoginSucceded(string accessToken)
{
var fb = new FacebookClient(accessToken);

        fb.GetCompleted += (o, e) =>
        {
            if (e.Error != null)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(e.Error.Message);
                    return;
                });
            }

            var result = (IDictionary<string, object>)e.GetResultData();
            var id = (string)result["id"];

            var url = string.Format("/Views/FacebookInfoPage.xaml?access_token={0}&id={1}", accessToken, id);
            var rootFrame = (App.Current as App).RootFrame;
            Deployment.Current.Dispatcher.BeginInvoke(() =>
               {
                   rootFrame.Navigate(new Uri(url, UriKind.Relative));
               });
        };

        fb.GetAsync("me?fields=id");
    }

In this method i am getting error in this line: fb.GetAsync("me?fields=id");

error..System.NotImplementedException: This property is not implemented by this class.
at System.Net.HttpWebRequest.SetUserAgent(String value)
at System.Net.HttpWebRequest.set_UserAgent(String value)
at Facebook.HttpWebRequestWrapper.set_UserAgent(String value)
at Facebook.HttpWebRequestWrapper.TrySetUserAgent(String userAgent)
at Facebook.FacebookClient.PrepareRequest(HttpMethod httpMethod, String path, Object parameters,
Type resultType, Stream& input, Boolean& containsEtag, IList`1& batchEtags)
at Facebook.FacebookClient.ApiAsync(HttpMethod httpMethod, String path, Object parameters, Type resultType, Object userState)
at Facebook.FacebookClient.GetAsync(String path, Object parameters, Object userState)
at Facebook.FacebookClient.GetAsync(String path)
at TestReactive.com.beno.WP7Client.ViewModels.FacebookViewModel.LoginSucceded(String accessToken)
at TestReactive.com.beno.WP7Client.ViewModels.FacebookViewModel.webBrowser_Navigated(Object sender, NavigationEvPID:0ED1004E TID:0F8A0042 entArgs e)
at Microsoft.Phone.Controls.WebBrowser.FireNavigatedEvent(Uri uri)
at Microsoft.Phone.Controls.WebBrowserInterop.ReversePInvokeThunk.OnNavigated(Int32 webBrowserControlId, String uri)

Please help me to resolve this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.