Cristian Boariu
Cristian Boariu

Reputation: 9621

Show photos from my facebook page on my web site

I have some doubts:

I want to show the photos from my company facebook page on my company web site using C# SDK.

How can I do that with an access token which never expires? Or why my app id and app secret is not enough?

var fb = new FacebookWebClient("app_id", "app_secret");

If I only use this it says:

An active access token must be used to query information about the current user.

Basically I see non-sense to ask for a valid access token because it's not about to interact with any of my visitors' page but just simply show my photos from my company facebook page to them.

UPDATE: To get my app token I am doing:

var oauthClient = new FacebookOAuthClient
    {
        AppId = "app_id",
        AppSecret = "app_secret"
    };

    dynamic result = oauthClient.GetApplicationAccessToken();
    accessToken = result.access_token;

But now, how I can show photos from my account?

If I do it like:

var fb = new FacebookWebClient(accessToken);
    //Get the album data
    dynamic albums = fb.Get("app_id/albums");

I receive an empty JSON but I am sure that my account on facebook has several albums.

Upvotes: 0

Views: 435

Answers (1)

DMCS
DMCS

Reputation: 31880

Tokens can and do expire. You must have code in place to handle when it does.

Your appid and app secret are not enough because at least one of the page admins MUST grant access to the page to get photo data via the Graph API.

Remember, the API is not only Facebook's sandbox, but they also are the ones who built it, so you're going to have to play by their rules.

Upvotes: 1

Related Questions