Invalid Paramater Problem

Nov 6, 2008 at 9:21 PM
Hi i want make a facebook application but i have problems.Pls help me. i am taking invalid paramater problem on this line

  friends.Add(_fbService.friends.get(_fbService.API.uid));



All Code is:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using facebook;
using facebook.Types;
using System.Text;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
using Microsoft.Xml.Schema.Linq;
public partial class _Default : System.Web.UI.Page
{
    private facebook.Schema.user visitorInfo = new facebook.Schema.user();
    
    facebook.Components.FacebookService _fbService = new facebook.Components.FacebookService();
    
    private const string FACEBOOK_APPKEY = "e7747be2b5a4146231e647e6989473fb";  // From the Facebook application page
    private const string FACEBOOK_SECRET = "4b2cb875af4a02712409b846e09e45ba";  // From the Facebook application page

    string userId;

    protected void Page_Load(object sender, EventArgs e)
    {
        _fbService.ApplicationKey = FACEBOOK_APPKEY;
        _fbService.Secret = FACEBOOK_SECRET;
        _fbService.API.IsDesktopApplication = false;

        string sessionKey = Session["facebook_session_key"] as String;
        userId = Session["facebook_userId"] as String;

        // When the user uses the facebook login page, 
        // the redirect back here will have the auth_token in the query params
        string authToken = Request.QueryString["auth_token"];

        if (!String.IsNullOrEmpty(sessionKey))
        {
            _fbService.SessionKey = sessionKey;
            _fbService.uid =Convert.ToInt64(userId);
        }
        else if (!String.IsNullOrEmpty(authToken))
        {
           
            _fbService.CreateSession(authToken);
            Session["facebook_session_key"] = _fbService.SessionKey;
            Session["facebook_userId"] = _fbService.uid;
            Session["facebook_session_expires"] = _fbService.SessionExpires;
            
        }
        else
        {
            Response.Redirect(@"http://www.facebook.com/login.php?api_key=" +
                _fbService.ApplicationKey + @"&v=1.0");
        }

        if (!IsPostBack)
        {

            //visitorInfo = 
            
            ArrayList userinfoal = new ArrayList();
              userinfoal.Add(_fbService.users.getInfo(_fbService.API.uid));

              Label1.Text = ((facebook.Schema.user)userinfoal[0]).first_name + "'s favorite shops";
              Image1.ImageUrl = ((facebook.Schema.user)userinfoal[0]).picture.Width.ToString();

            // Use the FacebookService Component to populate Friends
              
            ArrayList friends= new ArrayList();
            
            friends.Add(_fbService.friends.get(_fbService.API.uid));
            for (int i = 0; i < friends.Count; i++)
                DropDownList2.Items.Add(((facebook.Schema.user)friends[i]).first_name);
        }
}

Developer
Nov 6, 2008 at 9:51 PM
As discussed in a few other places, this was a problem in the documentation for 2.0 RC3. Please download the official 2.0 release instead and use the documentation posted with it, which has the code corrected for 2.0.