简体   繁体   中英

Ionic app with option to attend facebook events

I'm doing a hybrid app using Ionic framework. I want to implement a facebook event system to attend some events. I have this:

         ngFB.api(
                    '/666945880120392/attending',
                    'GET',
                    {},
                    function(response) {
                        // Insert your code here
                    }
                );

and I have ngFB in my app.js file like this:

ngFB.init({appId: '[APP_ID]'});

The error I have is:

openfb.js:256 GET https://graph.facebook.comundefined/?access_token=undefined net::ERR_NAME_NOT_RESOLVED

I was looking for a solution but no answer. I also try in the developer facebook console and the answer is correct:

https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=666945880120392%2Fattending&version=v2.7

What it's happening? Thanks!

EDIT 1

Thanks to @e666 I did now this

ngFB.api({
    method: 'GET',
    path: '/666945880120392/attending'
}).then(function(response) {
   console.log(response);
}).catch(function(error) {
    console.error(error);
});

And the error now is that if I'm logged with an account always the return in the event is:

Object {data: Array[1], paging: Object}

And inside data is the name of another person, the unique person that is attending to the event and no the person who is logged with the access token. Thanks!

EDIT 2

I opened another question because this is not the result than I hope, I need to go to an event, no to get the list of the people that goes to the event. I have this now:

ngFB.api(
                    "/666945880120392/attending",
                    function (response) {
                        if (response && !response.error) {
                            console.dir(response);
                        }
                    }
                );

the access_token is ok, and the response is

openfb.js:256 GET https://graph.facebook.comundefined/?access_token=EAABlK6y7pOUBAN3CPWdZB5FL…LCpXL9Bd3ELHQZAA6EJc6cCheAxUUnL59ZCZAf7aROCapJxiu991fxjDkxmMO651rfuREwZDZD net::ERR_NAME_NOT_RESOLVED

In the page of facebook https://developers.facebook.com/tools/explorer/?method=POST&path=666945880120392%2Fattending&version=v2.5

The response is

{
  "error": {
    "message": "(#299) Requires extended permission: rsvp_event",
    "type": "OAuthException",
    "code": 299,
    "fbtrace_id": "G7HFJ48pbkx"
  }
}

But I have this permission. Can someone help me please?

First, the path is undefined because you don't use correctly the method api . That is how you need to use it :

ngFB.api({
    method: 'GET',
    path: '/666945880120392/attending'
}).then(function(response) {
   console.log(response);
}).catch(function(error) {
    console.error(error);
});

Furthermore, you have undefined in access_token . As I looked in the library code, I am not sure that you can use this library without login as a user to have an access_token .

To have an access_token you need to use this function :

ngFB.login({scope: 'email'}).then(function(response) {
   console.log('Access token' + response.authResponse.accessToken);
}).catch(function(error) {
    console.error(error);
});

The access_token will then be automatically attached to request that you make with OpenFB .

You can find more complete examples of how to use the library is the github here : https://github.com/ccoenraets/OpenFB/blob/master/indexng.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM