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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.