Android Tutorial OAuth Facebook Feeds

Based on Erels google services OAuth post I thought I'd try accessing the facebook Graph Api using a similar technique.

The hardest part as it turned out was creating the app on facebook as I needed to link my phone with my account and it didn't seem to want to do it. But eventually it worked.

It is similar to creating an app for the google services except that you need to create the website integration. This does no more than allow you to retrieve the Access Token from a returned uri, but it has to be registered here first, so in the list under 'Select how your app integrates with Facebook' choose Website, and enter a Site URL. I also added same thing to the App Domain, I'm not sure it was necessary, but it worked.

Once created you need to plug in the created values for Your AppID, Your AppSecret and Your URL redirect to the attached project and try it out.

The data is returned as a JSON string instead of XML so it is parsed differently. And neither does it require WebViewExtended as the token is returned as part of a URI. There is a lot of information available so have a look through the documentation. I haven't looked at posting feeds (and have no need to), so haven't included it but I wanted to try out the feed reading.
 

Attachments

  • ff.zip
    9.8 KB · Views: 1,055

Penfound

Active Member
Licensed User
Longtime User
I wish I was better at this but I am very glad you guys are around.

I have the appID, Secret and Url sorted
My app will connect with facebook and list the posts and I have found some good examples from Steve and NJDude but I really onyl want to do one thing at the moment post one of those messages on the wall.

"Fred just got a score of 3,000,00 playing whatever!"

Does anyone have a bit of code for doing this please?

Cheers
Penfound
 

Claudio57

Member
Licensed User
Longtime User
The application works perfectly. I would like to know if it is possible to write my own page instead of on the wall.
 

Claudio57

Member
Licensed User
Longtime User
WWWWWOOOOOOOOOWWWWWWWWWWWWWWWW.
Now works.
Thank you vb1992.
I put the page number (id) instead of "me".
vb1992 you are the best.
:)
 

Douglas Farias

Expert
Licensed User
Longtime User
what i use in RedirectUri ?
any url or need set facebook page?
 

Emiliano

Member
Licensed User
Longtime User
<portuguese>
Olá Douglas!
O parâmetro RedirectURI nesse caso pode ser qualquer URL, pois normalmente é utilizado para redirecionar o usuário de volta ao site que solicitou a autorização. Como no seu caso não é um site, e sim uma aplicação Android, esse parâmetro não tem utilidade. Observei também que no código original utiliza um parâmetro chamado "clientSecret", que corresponderia ao Segredo da Aplicação (OAuth), mas que num contexto de aplicações moveis não é utilizado (Pois se considera que a aplicação não é capas de conservar esse segredo a salvo). Não cheguei a testar no código, mas na teoria é assim mesmo.​
</portuguese>

<english>
Hi Douglas!
The parameter RedirectURI in this case can be any URL, because it is typically used to redirect the user back to the site requesting the authorization. As in your case is not a website, but an Android application, then this parameter has not practical use. I also observed that in the original source code there is a parameter named "clientSecret", which is the Application Secret (OAuth), but in the context of mobile applications is not used anyway (There is a general consent about the mobile applications inability to safeguard the secret). I did not actually test the code, but in theory is it this way.​
</english>
 

Douglas Farias

Expert
Licensed User
Longtime User
how can i get this ?

Basic Info (Default)
Basic info is part of every request for permissions. It includes several elements from a person's public profile and a list of their friends.

On the web, basic_info is implied with every request and isn't required, although the best practice is to include it. Passing basic_info is required on iOS and Android with every permission request.

A person's public profile refers to the following properties on the user object by default:

The friend list is the friend list node on the user object.

User permissionDescription
basic_info

Gives access to a subset of a person's public profile and friend list. Required when requesting permissions on iOS and Android.
 

catyinwong

Active Member
Licensed User
Longtime User
Mine didn't work. May I ask what should I use as the redirect URL? Does it allow any URL or a facebook-related one? Do i have to register in the developers.facebook as well????
 
Top