From c01926ec7764a06cd6d95d678a16c909ed65bfe1 Mon Sep 17 00:00:00 2001 From: Poon Wu Date: Tue, 20 Sep 2016 15:18:25 +0700 Subject: [PATCH] Fixed instagram (Laki7877/reachrabbit-client#148 Laki7877/reachrabbit-client#149 ) --- .../com/ahancer/rr/services/InstagramService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/ahancer/rr/services/InstagramService.java b/src/main/java/com/ahancer/rr/services/InstagramService.java index 1758a90..f93a2e9 100644 --- a/src/main/java/com/ahancer/rr/services/InstagramService.java +++ b/src/main/java/com/ahancer/rr/services/InstagramService.java @@ -13,9 +13,11 @@ import org.jinstagram.exceptions.InstagramException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import com.ahancer.rr.daos.MediaDao; +import com.ahancer.rr.exception.ResponseException; import com.ahancer.rr.response.AuthenticationResponse; import com.ahancer.rr.response.InstagramProfileResponse; import com.ahancer.rr.response.OAuthenticationResponse; @@ -111,8 +113,17 @@ public Instagram getInstance(String accessToken) { } public OAuthenticationResponse authenticate(String accessToken) throws Exception { Instagram instagram = getInstance(accessToken); + Instagram instagram2 = getInstance(getAdminAccessToken()); UserInfoData userInfo = instagram.getCurrentUserInfo().getData(); + try{ + if(instagram2.getUserInfo(userInfo.getId()).getData() == null) { + throw new ResponseException(HttpStatus.BAD_REQUEST, "error.influencer.media.instagram.notpublic"); + } + } catch(Exception e) { + throw new ResponseException(HttpStatus.BAD_REQUEST, "error.influencer.media.instagram.notpublic"); + } + AuthenticationResponse auth = authenticationService.influencerAuthentication(userInfo.getId(), "instagram"); List pages = new ArrayList(); pages.add(new OAuthenticationResponse.Page(userInfo.getId(), userInfo.getFullName(), userInfo.getProfilePicture(), BigInteger.valueOf(userInfo.getCounts().getFollowedBy())));