× Joomla Facebook Connect support forum

Topic-icon Reading App Requests when connecting

Active Subscriptions:

None
14 years 1 month ago #21632 by Ivan
Hi,

Im trying to read app requests in controlllers/loginregister.php

right before the app-> redirect in function login();

I would like to read the users requests . I have in libraries/facebook.php
    function getfbRequests(){
    try
                {

                   $response = $this->api(/me/apprequests);
        
                }
                catch (JFBCFacebookApiException $e)
                {
          
                }
               
                return $response;
                
    }

However when i make this declaration: $requests = $fbClient->getfbRequests(); i dont get any data.

I am requesting permissions when the link is clicked withing the canvas. and If i send a request and login externally i do get the request data.

Is there another way or call that i can use to get a list of requests when i log in.
The topic has been locked.
Active Subscriptions:

None
14 years 1 month ago #21633 by Ivan
I forgot to mention i am doing this for new users, after granting permission and autlogin with the method in the thread after modifications to the system plugin

Auto login works but i cannot read the requests as before. I was able to read the request ids from the url but not this is not the case.
I want to detect if the user has a request and if he does read that request when logs in.

If i send a request and login to the site i outside of the canvas i get the request data.

Its only when im log in via the request link inside the canvas and auto login that i dont get any data.


I also tried this in controllers/loginregister.php right before the app redirect call. It only works when i log into the site and not when i auto login within the canvas through a request.
       $token_url = 'https://graph.facebook.com/oauth/access_token?'
            . 'client_id=' . $appId
            . '&client_secret=' . $appSecret
            . '&grant_type=client_credentials';

  $access_token = file_get_contents($token_url);

  //Get all app requests for user
  $request_url ="https://graph.facebook.com/" .
  $fbUserId . "/apprequests?".
  $access_token;
  $requests = file_get_contents($request_url);

$data = json_decode($requests);

The topic has been locked.
Support Specialist
14 years 1 month ago #21659 by alzander
Ivan,
The reason that you can't access the request is because JFBConnect processes requests when the user has approved your application and visits your Canvas page. That's a feature of the Requests functionality in JFBConnect.

If you want to stop JFBConnect from deleting the requests that were sent with the user in the query string when directed to your page, you can do so by editing the /components/com_jfbconnect/libraries/request.php file. Around line 62, look for:
foreach ($notificationModel->getRequestsToDelete() as $sig)
        {
            //echo "Deleting ".$sig."<br/>";
            $this->jfbcLibrary->api('/'.$sig, null, false, 'DELETE');
        }
Simply comment that out, and you should be good to go. However, please note that this means you will be responsible for deleting requests for the user or else they will simply stay in the user's Facebook inbox, which is a poor user experience.

Hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
14 years 1 month ago #21714 by Ivan
Thanks Alex this worked. Is there any word on when jfbconnect update for 1.5 will be released?
The topic has been locked.
Support Specialist
14 years 1 month ago #21722 by alzander
Glad to hear that got you going!

The update was *just* posted now. As with new releases for everything, backup first and test, but so far, things are looking very good. It's been running on SourceCoast since last Saturday without issue.

A similar change to what we posted above will be required for the new release to prevent Requests from being deleted. Figure you know that, but want to point it out anyways.

Thanks, and good luck!
Alex
The topic has been locked.