ChatterService.Web.ChatterProxyService.IsUserFollowing C# (CSharp) Method

IsUserFollowing() public method

public IsUserFollowing ( string viewerId, string ownerId, string accessToken ) : CommonResult
viewerId string
ownerId string
accessToken string
return CommonResult
        public CommonResult IsUserFollowing(string viewerId, string ownerId, string accessToken)
        {
            try
            {
                ChatterSoapService soap = getChatterSoapService();
                var ssOwnerId = getSalesforceUserId(soap, ownerId);
                var ssViewerId = getSalesforceUserId(soap, viewerId);

                ChatterRestService rest = getChatterRestService(accessToken);
                ChatterResponse cresp = rest.GetFollowers(ssOwnerId);
                int total = cresp != null ? cresp.total : 0;

                while (cresp != null && cresp.followers != null)
                {
                    foreach (ChatterSubscription csub in cresp.followers)
                    {
                        if (csub.subscriber != null && csub.subscriber.id.StartsWith(ssViewerId))
                        {
                            return new CommonResult() { Success = true, Following = true, Total = total, AccessToken = rest.GetAccessToken() };
                        }
                    }
                    cresp = rest.GetNextPage(cresp);
                }

                return new CommonResult() { Success = true, Following = false, Total = total, AccessToken = rest.GetAccessToken() };
            }
            catch (Exception ex)
            {
                HandleError(ex, url);
                HandleError(ex, accessToken);
                return new CommonResult() { Success = false, ErrorMessage = ex.Message };
            }
        }