/** * Subscribe to notifications for the current user. * * @param Google_MirrorService $service Authorized Mirror service. * @param string $collection Collection to subscribe to (supported * values are "timeline" and "locations"). * @param string $user_token Opaque token used by the Service to * identify the user the notification pings * are sent for (recommended). * @param string $callback_url URL receiving notification pings (must be HTTPS). */ function subscribe_to_notifications($service, $collection, $user_token, $callback_url) { try { $subscription = new Google_Subscription(); $subscription->setCollection($collection); $subscription->setUserToken($user_token); $subscription->setCallbackUrl($callback_url); $service->subscriptions->insert($subscription); return "Subscription inserted!"; } catch (Exception $e) { return 'An error occurred: ' . $e->getMessage(); } }