Greetings. I have a bit of situation here. I'm using symfony2 and facebook SDK to set up a web service for my IPhone and Android applications. The problem is that the background work can take quite a while. User is first redirected to facebook login page where he can proceed by accepting my facebook app permissions. So, instead of waiting for my service to complete background work, user should be notified immediately that everything is in order. Service should continue work in background and user should be unaware of it. These are the first few lines of my controller:

        $em = $this->getDoctrine()->getManager();
        $facebook = new \Facebook(array(
            'appId' => '************',
            'secret' => '*************************',
            'fileUpload' => false, 
            'allowSignedRequest' => false, 
        $user_id = $facebook->getUser();
        $location = "" . $facebook->getLoginUrl(array('scope' => 'read_stream'));

        if ($user_id) {
            try {
                $fb_user_profile = $facebook->api('/me');
            } catch (FacebookApiException $e) {
                $user_id = NULL;
                print '<script language="javascript" type="text/javascript"> top.location.href="' . $location . '</script>';
        } else {
            print '<script language="javascript" type="text/javascript"> top.location.href="' . $location . '"; </script>';

After this controller should call some other function which will do the heavy lifting, preferably by creating another thread. I have never done something like this in PHP. What is the best practice for this kind of problem? Any thoughts?

Edited by Dr_Freeman

3 Years
Discussion Span
Last Post by chrishea
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.