I am using Facebook C# SDk 4.1.1 to develop an application. Is there anyone has a complete sample code for asp.net forms including web config settings? I am really tired making the sample code to work. I believe I am using the correct settings in both facebook app registration and web.Config file
The issue is: When I run my test project from Visual studio it is taking to facebook log in page. After I log in, the app is requesting to authorize it. Once I click on allow button, the brwoser is redirecting to a very long url that has several parameters. But the response is server error.
Can any one explain me what to do once the user clicks on Allow button? I can really appreciate if you can provide me step by step procedure. Thanks
Facebook App Registration Settings
App ID XXXXXXXXXXXXX
API Key xxxxxxxxxxxxxxxxxxxxxxx
App Secret xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Canvas Page apps.facebook.com/smartbuttonthree/
Canvas URL preview.smartbutton.com/dev/
Canvas FBML/iframe iframe
Note: In this post I removed 'http://' for Canvas Page and Canvas URL as I couldn't post more than 1 hyperlink.
Web.COnfig file
<configuration>
<configSections>
<section type="Facebook.FacebookConfigurationSection, Facebook" name="facebookSettings"/>
<section name="canvasSettings" type="Facebook.Web.CanvasConfigurationSettings, Facebook.Web" />
</configSections>
<facebookSettings appId="xxxxxxxx" appSecret="xxxxxxx" cookieSupport="true" />
<canvasSettings
canvasPageUrl="http://apps.facebook.com/smartbuttonthree/"
canvasUrl="https://preview.smartbutton.com/dev/"
authorizeCancelUrl="http://www.facebook.com"/>
<system.web>
<httpHandlers>
<add verb="*" path="facebookredirect.axd" type="Facebook.Web.FacebookAppRedirect开发者_如何学JAVAHttpHandler, Facebook.Web" />
</httpHandlers>
<compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
<sessionState mode="Off" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<defaultDocument>
<files>
<clear />
<add value="Default.aspx" />
</files>
</defaultDocument>
<handlers>
<add name="facebookredirect.axd" path="facebookredirect.axd" verb="*"
type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" />
</handlers>
</system.webServer>
</configuration>
Default.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fbApp = New FacebookApp()
authorizer = New CanvasAuthorizer(fbApp)
authorizer.Perms = requiredAppPermissions
If (authorizer.Authorize()) Then
showFacebookContent()
End If
End Sub
Private Sub showFacebookContent()
Dim myInfo = fbApp.Get("me")
lblName.Text = "Welcome " & myInfo.name
End Sub
Update: The app works if I browse to the app (apps.facebook.com/smartbuttonthree) before I log in to facebook account.
App does not work if I log in to facebook first and then browse to apps.facebook.com/smartbuttonthree/
I found a good starter site here. It is a sample website in C# . You need to use your own API key and secret key to run this app.
Facebook C# Sdk Sample website
Looks like you got this figured out but if you're still looking for a complete sample, check out my open source ASP.NET 4.0 Facebook Canvas app built with the Facebook C# SDK at http://code.google.com/p/facebooksteamachievements/.
精彩评论