Closed laura2489 closed 7 years ago
Hey @laura2489 ,
I do plan on improving the documentation and adding examples. But for now, is there a specific thing that you're trying to do that I can help out with?
Here is a quick example on how to use the api
method:
class MyComponent {
constructor(private fb: FacebookService){ .. }
getMyProfile() {
// must login before using `api`
this.fb.api('/me')
.then(res => console.log(res))
.catch(error => console.error(error));
}
}
Thank you for your prompt response. I tried that, and i keep getting the following error: "An active access token must be used to query information about the current user." If i provide the token, instead of /me, i get the following error: "(#803) Some of the aliases you requested do not exist: null"
@laura2489 you need to call the login
method and successfully login before using the api
method.
I did login and i managed to get the token using this.FB.getAuthResponse(). Do I have to set the token globally or something?
{"accessToken":"EAAac7879mTwBAMevlLWBbZAHnshAr8w9VBQmE8cbBZCagi6utcMZAqoG3w8ZC5YdbWITT7M28dDJg8H7oGvshTWVNydGe2F0WkJZAvYmew6W9uuGdQWgPACwlTRdZAgRijK5NgeFoGxZB0OWGTx8n9An2uFCuz0WBLdmUAAI3ahjg2ZBlRaPtNFYZBLuShuU5KvYZD","userID":"........,"expiresIn":4639...."}
i saved it in localStorage.setItem('accessToken', ....); but still nothing :(
I should mention that i use Angular 2 with Webpack.
Please see the usage here: https://github.com/zyramedia/ng2-facebook-sdk-example
To use the api
method, you need to call the login
method first. You need to login the user every time they access your app. If they have already authorized your app, then the dialog will close immediately and the session will be restored.
Thank you very much. The example you posted helped me a lot. Now it works.
Glad to help!
How can I get user permissions for an app?
@alex-chaliy
I think there's an end point like /<app-id>/permissions
.. check their docs :)
@ihadeed thank you so much for your example, helped me a lot!!
I managed to log in an get the accessToken, but the api method doesn't seem to work or i don't know how to use it. Examples would be great. Thanks.