void TwitterFeedService::HandleAuthResponse(Eegeo::Web::IWebResponse& webResponse) { m_pCurrentAuthRequest = NULL; if(webResponse.GetHttpStatusCode() != 200) { m_currentServiceState = OFFLINE; ClearAccountNameQueue(); return; } size_t resultSize = webResponse.GetBodyData().size(); std::string serialized(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize); rapidjson::Document document; document.Parse<0>(serialized.c_str()); Eegeo_ASSERT(!document.HasParseError(), "Error parsing auth response"); Eegeo_ASSERT(document.HasMember(AccessTokenKey.c_str()), "Auth response doesn't contain access code: %s", serialized.c_str()); m_accessToken = std::string(document[AccessTokenKey.c_str()].GetString()); LoadNextTimeLine(); }
void TwitterFeedService::HandleTimeLineResponse(Eegeo::Web::IWebResponse& webResponse) { m_pCurrentTimeLineRequest = NULL; if(webResponse.GetHttpStatusCode() != 200) { m_currentServiceState = OFFLINE; ClearAccountNameQueue(); return; } size_t resultSize = webResponse.GetBodyData().size(); std::string serialized(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize); rapidjson::Document document; document.Parse<0>(serialized.c_str()); Eegeo_ASSERT(!document.HasParseError(), "Error parsing timeline request response") Eegeo_ASSERT(document.IsArray(), "Timeline request response unrecognised: %s", serialized.c_str()); std::map<std::string, TweetRepository*>::iterator repositoryIt = m_repositoryMap.find(m_accountNameQueue.front()); if(repositoryIt == m_repositoryMap.end()) { repositoryIt = m_repositoryMap.insert(std::pair<std::string, TweetRepository*>(m_accountNameQueue.front(), Eegeo_NEW(TweetRepository)())).first; } TweetRepository* currentRepository = (*repositoryIt).second; for(rapidjson::SizeType i = 0; i < document.Size(); ++i) { currentRepository->AddItem(TweetModel::GetNewTweetModelFromJsonDocument(document, i)); } m_feedLoadedCallbacks.ExecuteCallbacks(m_accountNameQueue.front(), *currentRepository); m_accountNameQueue.pop(); LoadNextTimeLine(); }
void MyPinsWebService::WebRequestCompleteCallback(Eegeo::Web::IWebResponse& webResponse) { size_t resultSize = webResponse.GetBodyData().size(); std::string responseString = resultSize > 0 ? std::string(reinterpret_cast<char const*>(&(webResponse.GetBodyData().front())), resultSize) : "<empty>"; Eegeo_TTY("Web Request Completed, code: %d response: %s\n", webResponse.GetHttpStatusCode(), responseString.c_str()); }