Example usage for org.json JSONObject getJSONObject

List of usage examples for org.json JSONObject getJSONObject

Introduction

In this page you can find the example usage for org.json JSONObject getJSONObject.

Prototype

public JSONObject getJSONObject(String key) throws JSONException 

Source Link

Document

Get the JSONObject value associated with a key.

Usage

From source file:org.cloudfoundry.client.lib.util.JsonUtil.java

public static Map<String, Object> convertJsonToMap(JSONObject json) throws JSONException {
    Map<String, Object> retMap = new HashMap<String, Object>();
    JSONObject jo = new JSONObject(json.toString());
    for (String key : JsonUtil.keys(jo)) {
        if (jo.get(key.toString()) instanceof JSONObject) {
            retMap.put(key.toString(), convertJsonToMap(jo.getJSONObject(key.toString())));
        } else {//from w  w w  . j ava  2  s  .co m
            retMap.put(key.toString(), jo.getString(key.toString()));
        }
    }
    return retMap;
}

From source file:org.brickred.socialauth.provider.SalesForceImpl.java

/**
 * @return/* w  ww  .  j a  v  a2  s  .  c  o  m*/
 * @throws Exception
 */
private Profile getProfile() throws Exception {
    if (accessGrant.getAttribute("id") != null) {
        profileURL = (String) accessGrant.getAttribute("id");
    }
    LOG.debug("Profile URL : " + profileURL);
    Profile p = new Profile();
    Map<String, String> headerParam = new HashMap<String, String>();
    headerParam.put("Authorization", "OAuth " + accessGrant.getKey());
    headerParam.put("Content-Type", "application/json");
    headerParam.put("Accept", "application/json");
    Response serviceResponse;
    try {
        serviceResponse = authenticationStrategy.executeFeed(profileURL, MethodType.GET.toString(), null,
                headerParam, null);
        // HttpUtil.doHttpRequest(profileURL, "GET", null, headerParam);
    } catch (Exception e) {
        throw new SocialAuthException("Failed to retrieve the user profile from  " + profileURL, e);
    }

    String result;
    try {
        result = serviceResponse.getResponseBodyAsString(Constants.ENCODING);
        LOG.debug("User Profile :" + result);
    } catch (Exception e) {
        throw new SocialAuthException("Failed to read response from  " + profileURL, e);
    }
    try {
        JSONObject resp = new JSONObject(result);
        if (resp.has("user_id")) {
            p.setValidatedId(resp.getString("user_id"));
        }
        if (resp.has("first_name")) {
            p.setFirstName(resp.getString("first_name"));
        }
        if (resp.has("last_name")) {
            p.setLastName(resp.getString("last_name"));
        }
        p.setDisplayName(resp.getString("display_name"));

        p.setEmail(resp.getString("email"));
        String locale = resp.getString("locale");
        if (locale != null) {
            String a[] = locale.split("_");
            p.setLanguage(a[0]);
            p.setCountry(a[1]);
        }
        if (resp.has("photos")) {
            JSONObject photosResp = resp.getJSONObject("photos");

            if (p.getProfileImageURL() == null || p.getProfileImageURL().length() <= 0) {
                p.setProfileImageURL(photosResp.getString("thumbnail"));
            }
        }
        serviceResponse.close();
        p.setProviderId(getProviderId());
        userProfile = p;
        return p;
    } catch (Exception e) {
        throw new SocialAuthException("Failed to parse the user profile json : " + result, e);

    }
}

From source file:fi.kinetik.android.currencies.spi.openexchange.OpenExchangeRatesSpi.java

private void parseRates(ArrayList<ContentProviderOperation> operations, JSONObject jsonObj)
        throws JSONException {

    final long updated = jsonObj.getLong(Keys.TIMESTAMP);
    final String base = jsonObj.getString(Keys.BASE);
    final JSONObject rates = jsonObj.getJSONObject(Keys.RATES);
    final Iterator iter = rates.keys();

    while (iter.hasNext()) {

        final String currency = (String) iter.next();
        final double rate = rates.getDouble(currency);

        operations.add(ConversionRate.newUpdateOperation(currency, OpenExchangeRatesSpiFactory.PROVIDER_NAME,
                updated, rate));/* w  ww.j a v a2  s  .  c  o  m*/
    }

}

From source file:cn.kangeqiu.kq.activity.GroupDetailsActivity.java

private void initDate() {
    adapter.clear();/*from w  w w .  j  a  v  a  2  s  .c  o m*/
    memberIds = "";
    doPullDate(false, "2050", new MCHttpCallBack() {

        @Override
        public void onSuccess(MCHttpResp resp) {
            super.onSuccess(resp);
            try {
                String resultCode = resp.getJson().getString("result_code");
                if (resultCode.equals("0")) {
                    JSONObject room = resp.getJson().getJSONObject("room");
                    hourse_name.setText(room.getString("name"));
                    invite_number.setText(room.getString("invitation_code"));
                    member_sum.setText("? (" + room.getString("member_count") + "/"
                            + room.getString("max_member_count") + ")");
                    JSONObject match = resp.getJson().getJSONObject("match");

                    match_name.setText(match.getJSONObject("team1").getString("name") + "VS"
                            + match.getJSONObject("team2").getString("name"));

                    JSONArray records = resp.getJson().getJSONArray("records");
                    // 
                    shareUtil.setShareContent(
                            "?" + room.getString("name") + ""
                                    + "???????",
                            records.getJSONObject(0).getString("icon"));
                    List<MemberInfoModel> memberArray = new ArrayList<MemberInfoModel>();

                    for (int i = 0; i < records.length(); i++) {
                        MemberInfoModel member = new MemberInfoModel();
                        member.setIcon(records.getJSONObject(i).getString("icon"));
                        member.setName(records.getJSONObject(i).getString("nickname"));
                        member.setId(records.getJSONObject(i).getString("id"));

                        memberIds += "," + records.getJSONObject(i).getString("id");
                        memberArray.add(member);
                    }
                    adapter.setMembers(memberArray);
                } else {
                    Toast.makeText(GroupDetailsActivity.this, resp.getJson().getString("message"),
                            Toast.LENGTH_SHORT).show();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        @Override
        public void onError(MCHttpResp resp) {
            super.onError(resp);
            Toast.makeText(GroupDetailsActivity.this, resp.getErrorMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:cn.kangeqiu.kq.activity.GroupDetailsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    shareUtil.ssoResult(requestCode, resultCode, data);
    String st1 = getResources().getString(R.string.being_added);
    String st2 = getResources().getString(R.string.is_quit_the_group_chat);
    String st3 = getResources().getString(R.string.chatting_is_dissolution);
    String st4 = getResources().getString(R.string.are_empty_group_of_news);
    String st5 = getResources().getString(R.string.is_modify_the_group_name);
    final String st6 = getResources().getString(R.string.Modify_the_group_name_successful);
    final String st7 = getResources().getString(R.string.change_the_group_name_failed_please);
    String st8 = getResources().getString(R.string.Are_moving_to_blacklist);
    final String st9 = getResources().getString(R.string.failed_to_move_into);

    final String stsuccess = getResources().getString(R.string.Move_into_blacklist_success);
    if (resultCode == RESULT_OK) {
        if (progressDialog == null) {
            progressDialog = new ProgressDialog(GroupDetailsActivity.this);
            progressDialog.setMessage(st1);
            progressDialog.setCanceledOnTouchOutside(false);
        }//from w  w  w  . ja v  a2 s . co m
        switch (requestCode) {
        case REQUEST_CODE_ADD_USER:// ?
            // final String[] newmembers = data
            // .getStringArrayExtra("newmembers");
            newIds = data.getStringExtra("id");
            progressDialog.setMessage(st1);
            progressDialog.show();
            addMembersToGroup();
            break;
        case REQUEST_CODE_EXIT: // 
            progressDialog.setMessage(st2);
            progressDialog.show();
            exitGrop();
            break;
        case REQUEST_CODE_EXIT_DELETE: // 
            progressDialog.setMessage(st3);
            progressDialog.show();
            deleteGrop();
            break;
        case REQUEST_CODE_CLEAR_ALL_HISTORY:
            // ??
            progressDialog.setMessage(st4);
            progressDialog.show();
            clearGroupHistory();
            break;

        case REQUEST_CODE_EDIT_GROUPNAME: // ??
            final String returnData = data.getStringExtra("data");
            hourse_name.setText(returnData);
            Toast.makeText(getApplicationContext(), st6, 0).show();
            // ((TextView) findViewById(R.id.group_name)).setText(returnData
            // + "("
            // + group.getAffiliationsCount()
            // + st);

            // if (!TextUtils.isEmpty(returnData)) {
            // progressDialog.setMessage(st5);
            // progressDialog.show();
            //
            // new Thread(new Runnable() {
            // public void run() {
            // try {
            // EMGroupManager.getInstance().changeGroupName(
            // groupId, returnData);
            // runOnUiThread(new Runnable() {
            // public void run() {
            // ((TextView) findViewById(R.id.group_name)).setText(returnData
            // + "("
            // + group.getAffiliationsCount()
            // + st);
            // progressDialog.dismiss();
            // Toast.makeText(getApplicationContext(),
            // st6, 0).show();
            // }
            // });
            //
            // } catch (EaseMobException e) {
            // e.printStackTrace();
            // runOnUiThread(new Runnable() {
            // public void run() {
            // progressDialog.dismiss();
            // Toast.makeText(getApplicationContext(),
            // st7, 0).show();
            // }
            // });
            // }
            // }
            // }).start();
            // }
            break;
        case REQUEST_CODE_ADD_TO_BALCKLIST:
            progressDialog.setMessage(st8);
            progressDialog.show();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        EMGroupManager.getInstance().blockUser(groupId, longClickUsername);
                        runOnUiThread(new Runnable() {
                            public void run() {
                                refreshMembers();
                                progressDialog.dismiss();
                                Toast.makeText(getApplicationContext(), stsuccess, 0).show();
                            }
                        });
                    } catch (EaseMobException e) {
                        runOnUiThread(new Runnable() {
                            public void run() {
                                progressDialog.dismiss();
                                Toast.makeText(getApplicationContext(), st9, 0).show();
                            }
                        });
                    }
                }
            }).start();

            break;
        default:
            break;
        }
    } else if (resultCode == 30) {
        try {
            final JSONObject jsonMatch = new JSONObject(data.getStringExtra("match"));
            matchId = jsonMatch.getString("id");
            CPorgressDialog.showProgressDialog(GroupDetailsActivity.this);
            doPullDate(false, "2053", new MCHttpCallBack() {
                @Override
                public void onSuccess(MCHttpResp resp) {
                    super.onSuccess(resp);
                    CPorgressDialog.hideProgressDialog();
                    try {
                        String resultCode = resp.getJson().getString("result_code");
                        if (resultCode.equals("0")) {
                            match_name.setText(jsonMatch.getJSONObject("team1").getString("name") + "VS"
                                    + jsonMatch.getJSONObject("team2").getString("name"));
                        } else {
                            Toast.makeText(GroupDetailsActivity.this, resp.getJson().getString("message"),
                                    Toast.LENGTH_SHORT).show();
                        }
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                @Override
                public void onError(MCHttpResp resp) {
                    super.onError(resp);
                    CPorgressDialog.hideProgressDialog();
                }
            });
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

    }
}

From source file:edu.msu.walajahi.sunshine.app.FetchWeatherTask.java

/**
 * Take the String representing the complete forecast in JSON Format and
 * pull out the data we need to construct the Strings needed for the wireframes.
 *
 * Fortunately parsing is easy:  constructor takes the JSON string and converts it
 * into an Object hierarchy for us./*w w w  .j av  a2 s. com*/
 */
private void getWeatherDataFromJson(String forecastJsonStr, String locationSetting) throws JSONException {

    // Now we have a String representing the complete forecast in JSON Format.
    // Fortunately parsing is easy:  constructor takes the JSON string and converts it
    // into an Object hierarchy for us.

    // These are the names of the JSON objects that need to be extracted.

    // Location information
    final String OWM_CITY = "city";
    final String OWM_CITY_NAME = "name";
    final String OWM_COORD = "coord";

    // Location coordinate
    final String OWM_LATITUDE = "lat";
    final String OWM_LONGITUDE = "lon";

    // Weather information.  Each day's forecast info is an element of the "list" array.
    final String OWM_LIST = "list";

    final String OWM_PRESSURE = "pressure";
    final String OWM_HUMIDITY = "humidity";
    final String OWM_WINDSPEED = "speed";
    final String OWM_WIND_DIRECTION = "deg";

    // All temperatures are children of the "temp" object.
    final String OWM_TEMPERATURE = "temp";
    final String OWM_MAX = "max";
    final String OWM_MIN = "min";

    final String OWM_WEATHER = "weather";
    final String OWM_DESCRIPTION = "main";
    final String OWM_WEATHER_ID = "id";

    try {
        JSONObject forecastJson = new JSONObject(forecastJsonStr);
        JSONArray weatherArray = forecastJson.getJSONArray(OWM_LIST);

        JSONObject cityJson = forecastJson.getJSONObject(OWM_CITY);
        String cityName = cityJson.getString(OWM_CITY_NAME);

        JSONObject cityCoord = cityJson.getJSONObject(OWM_COORD);
        double cityLatitude = cityCoord.getDouble(OWM_LATITUDE);
        double cityLongitude = cityCoord.getDouble(OWM_LONGITUDE);

        long locationId = addLocation(locationSetting, cityName, cityLatitude, cityLongitude);

        // Insert the new weather information into the database
        Vector<ContentValues> cVVector = new Vector<ContentValues>(weatherArray.length());

        // OWM returns daily forecasts based upon the local time of the city that is being
        // asked for, which means that we need to know the GMT offset to translate this data
        // properly.

        // Since this data is also sent in-order and the first day is always the
        // current day, we're going to take advantage of that to get a nice
        // normalized UTC date for all of our weather.

        Time dayTime = new Time();
        dayTime.setToNow();

        // we start at the day returned by local time. Otherwise this is a mess.
        int julianStartDay = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);

        // now we work exclusively in UTC
        dayTime = new Time();

        for (int i = 0; i < weatherArray.length(); i++) {
            // These are the values that will be collected.
            long dateTime;
            double pressure;
            int humidity;
            double windSpeed;
            double windDirection;

            double high;
            double low;

            String description;
            int weatherId;

            // Get the JSON object representing the day
            JSONObject dayForecast = weatherArray.getJSONObject(i);

            // Cheating to convert this to UTC time, which is what we want anyhow
            dateTime = dayTime.setJulianDay(julianStartDay + i);

            pressure = dayForecast.getDouble(OWM_PRESSURE);
            humidity = dayForecast.getInt(OWM_HUMIDITY);
            windSpeed = dayForecast.getDouble(OWM_WINDSPEED);
            windDirection = dayForecast.getDouble(OWM_WIND_DIRECTION);

            // Description is in a child array called "weather", which is 1 element long.
            // That element also contains a weather code.
            JSONObject weatherObject = dayForecast.getJSONArray(OWM_WEATHER).getJSONObject(0);
            description = weatherObject.getString(OWM_DESCRIPTION);
            weatherId = weatherObject.getInt(OWM_WEATHER_ID);

            // Temperatures are in a child object called "temp".  Try not to name variables
            // "temp" when working with temperature.  It confuses everybody.
            JSONObject temperatureObject = dayForecast.getJSONObject(OWM_TEMPERATURE);
            high = temperatureObject.getDouble(OWM_MAX);
            low = temperatureObject.getDouble(OWM_MIN);

            ContentValues weatherValues = new ContentValues();

            weatherValues.put(WeatherEntry.COLUMN_LOC_KEY, locationId);
            weatherValues.put(WeatherEntry.COLUMN_DATE, dateTime);
            weatherValues.put(WeatherEntry.COLUMN_HUMIDITY, humidity);
            weatherValues.put(WeatherEntry.COLUMN_PRESSURE, pressure);
            weatherValues.put(WeatherEntry.COLUMN_WIND_SPEED, windSpeed);
            weatherValues.put(WeatherEntry.COLUMN_DEGREES, windDirection);
            weatherValues.put(WeatherEntry.COLUMN_MAX_TEMP, high);
            weatherValues.put(WeatherEntry.COLUMN_MIN_TEMP, low);
            weatherValues.put(WeatherEntry.COLUMN_SHORT_DESC, description);
            weatherValues.put(WeatherEntry.COLUMN_WEATHER_ID, weatherId);

            cVVector.add(weatherValues);
        }

        int inserted = 0;
        // add to database
        if (cVVector.size() > 0) {
            // Student: call bulkInsert to add the weatherEntries to the database here
            ContentValues[] cvArray = new ContentValues[cVVector.size()];
            cVVector.toArray(cvArray);
            inserted = mContext.getContentResolver().bulkInsert(WeatherEntry.CONTENT_URI, cvArray);
        }
        Log.d(LOG_TAG, "FetchWeatherTask Complete. " + inserted + " Inserted");

    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    }
}

From source file:com.extremeboredom.wordattack.utils.JSONUtils.java

/**
 * get JSONObject from jsonObject/*w ww . j  a  v  a 2 s.  c o  m*/
 *
 * @param jsonObject
 * @param key
 * @param defaultValue
 * @return <ul>
 * <li>if jsonObject is null, return defaultValue</li>
 * <li>if key is null or empty, return defaultValue</li>
 * <li>if {@link JSONObject#getJSONObject(String)} exception, return defaultValue</li>
 * <li>return {@link JSONObject#getJSONObject(String)}</li>
 * </ul>
 */
public static JSONObject getJSONObject(JSONObject jsonObject, String key, JSONObject defaultValue) {
    if (jsonObject == null || StringUtils.isEmpty(key)) {
        return defaultValue;
    }

    try {
        return jsonObject.getJSONObject(key);
    } catch (JSONException e) {
        if (isPrintException) {
            e.printStackTrace();
        }
        return defaultValue;
    }
}

From source file:org.entando.entando.plugins.jptrello.aps.system.services.trello.TrelloConfig.java

public TrelloConfig(String xml) {
    if (StringUtils.isNotBlank(xml)) {
        JSONObject json = XML.toJSONObject(xml);
        json = json.getJSONObject(CONFIG_ROOT);

        if (json.has(CONFIG_ORGANIZATION)) {
            _organization = json.getString(CONFIG_ORGANIZATION);
        }//from w  ww. java 2s  .  c om
        if (json.has(CONFIG_KEY)) {
            _apiKey = json.getString(CONFIG_KEY);
        }
        if (json.has(CONFIG_SECRET)) {
            _apiSecret = json.getString(CONFIG_SECRET);
        }
        if (json.has(CONFIG_TOKEN)) {
            _token = json.getString(CONFIG_TOKEN);
        }
    }
}

From source file:actuatorapp.ActuatorApp.java

public void commandFromApi(JSONObject command) throws JSONException {
    //Takes the command and processes it
    try {/*www  . j a  v  a 2 s. c o  m*/
        String type = (String) command.get("type");
        if (type.equals("control") == true) {
            System.out.println(command);
            String yocto_addr = (String) command.get("yocto_addr");
            JSONObject payload = command.getJSONObject("payload");
            boolean value = (Boolean) payload.getBoolean("value");

            setActuatorState(yocto_addr, value);
        } else {
            System.out.println("Wrong command recieved");
        }
    } catch (Exception e) {
        System.out.println("Error on command SEND");
    }

}

From source file:ai.ilikeplaces.logic.sits9.SubscriberNotifications.java

@Timeout
synchronized public void timeout(final Timer timer)
        throws IOException, SAXException, TransformerException, JSONException, SQLException {

    final HBaseCrudService<GeohashSubscriber> _geohashSubscriberHBaseCrudService = new HBaseCrudService<GeohashSubscriber>();
    final HBaseCrudService<GeohashSubscriber>.Scanner _scanner = _geohashSubscriberHBaseCrudService
            .scan(new GeohashSubscriber(), 1).returnValueBadly();

    while (_scanner.getNewValue() != null) {
        final String _newValue = _scanner.getNewValue();
        Loggers.debug("Scanned value:" + _newValue);
        final RowResponse _rowResponse = new Gson().fromJson(_newValue, RowResponse.class);
        Loggers.debug("Scanned as GSON:" + _rowResponse.toString());

        for (final Row _row : _rowResponse.Row) {

            final BASE64Decoder _base64DecoderRowKey = new BASE64Decoder();
            final byte[] _bytes = _base64DecoderRowKey.decodeBuffer(_row.key);
            final String rowKey = new String(_bytes);
            Loggers.debug("Decoded row key:" + rowKey);

            for (final Cell _cell : _row.Cell) {
                final BASE64Decoder _base64DecoderValue = new BASE64Decoder();
                final byte[] _valueBytes = _base64DecoderValue.decodeBuffer(_cell.$);
                final String _cellAsString = new String(_valueBytes);
                Loggers.debug("Cell as string:" + _cellAsString);
                final GeohashSubscriber _geohashSubscriber = new GeohashSubscriber();

                final DatumReader<GeohashSubscriber> _geohashSubscriberSpecificDatumReader = new SpecificDatumReader<GeohashSubscriber>(
                        _geohashSubscriber.getSchema());
                final BinaryDecoder _binaryDecoder = DecoderFactory.get().binaryDecoder(_valueBytes, null);
                final GeohashSubscriber _read = _geohashSubscriberSpecificDatumReader.read(_geohashSubscriber,
                        _binaryDecoder);
                Loggers.debug("Decoded value avro:" + _read.toString());

                final Date now = new Date();
                final Calendar _week = Calendar.getInstance();
                _week.setTimeInMillis(now.getTime() + (7 * 24 * 60 * 60 * 1000));
                final SimpleDateFormat _simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                _simpleDateFormat.format(_week.getTime());

                final StringBuffer eventList = new StringBuffer("");

                {//Eventful

                    try {

                        final SimpleDateFormat eventfulDate = new SimpleDateFormat("yyyyMMdd00");
                        _simpleDateFormat.format(_week.getTime());

                        final JSONObject jsonObject = Modules.getModules().getEventulFactory()
                                .getInstance("http://api.eventful.com/json/events/search/")
                                .get("", new HashMap<String, String>() {
                                    {//Don't worry, this is a static initializer of this map :)
                                        put("location", "" + _read.getLatitude() + "," + _read.getLongitude());
                                        put("within", "" + 100);
                                        put("date", eventfulDate.format(Calendar.getInstance().getTime()) + "-"
                                                + eventfulDate.format(_week.getTime()));
                                    }/* w ww.j  av a 2 s.co  m*/
                                }

                        );

                        Loggers.debug("Eventful Reply:" + jsonObject.toString());

                        final JSONArray events = jsonObject.getJSONObject("events").getJSONArray("event");

                        final Document eventTemplateDocument = HTMLDocParser
                                .getDocument(RBGet.getGlobalConfigKey("PAGEFILES") + SUBSCRIBER_EMAIL_EVENT);
                        final String eventTemplate = HTMLDocParser
                                .convertNodeToHtml(HTMLDocParser.$("content", eventTemplateDocument));

                        for (int i = 0; i < events.length(); i++) {
                            final JSONObject eventJSONObject = new JSONObject(events.get(i).toString());
                            Double.parseDouble(eventJSONObject.getString(LATITUDE));
                            Double.parseDouble(eventJSONObject.getString(LONGITUDE));
                            final String eventName = eventJSONObject.getString("title");
                            final String eventUrl = eventJSONObject.getString("url");
                            final String eventDate = eventJSONObject.getString("start_time");
                            final String eventVenue = eventJSONObject.getString("venue_name");
                            Loggers.debug("Event name:" + eventName);
                            eventList
                                    .append(eventTemplate
                                            .replace("_name_link_",
                                                    !(("" + eventUrl).isEmpty()) ? eventUrl
                                                            : ("https://www.google.com/search?q=" + eventName
                                                                    .replaceAll(" ", "+").replaceAll("-", "+")))
                                            .replace("_place_link_",
                                                    "https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=600x600&markers=color:blue%7Clabel:S%7C"
                                                            + _read.getLatitude().toString() + ","
                                                            + _read.getLongitude().toString())
                                            .replace("_name_", eventName).replace("_place_", eventVenue)
                                            .replace("_date_", eventDate));
                        }
                    } catch (final Throwable t) {
                        Loggers.error("Error appending Eventful data to Geohash Subscriber", t);
                    }
                }

                {//Foursquare

                    try {

                        _simpleDateFormat.format(_week.getTime());

                        final JSONObject jsonObject = Modules.getModules().getEventulFactory()
                                .getInstance("https://api.foursquare.com/v2/venues/explore")
                                .get("", new HashMap<String, String>() {
                                    {//Don't worry, this is a static initializer of this map :)
                                        put("ll", "" + _read.getLatitude() + "," + _read.getLongitude());
                                        put("radius", "" + 50000);//meters
                                        put("intent", "browse");
                                        put("section", "topPicks");
                                        put("client_secret",
                                                "PODRX5YWBSLAKAYRQ5CLPEPS3WHCXWFIJ3LXF3AKH4U1BDNI");
                                        put("client_id", "25JZAK3TQPLIPUUXPIJWXQ5NSKSPTP4SYZLUZSCTZF3UJ4YX");
                                    }
                                }

                        );

                        Loggers.debug("Foursquare Reply:" + jsonObject.toString());

                        final JSONArray referralArray = jsonObject.getJSONObject("response")
                                .getJSONArray("groups").getJSONObject(0).getJSONArray("items");

                        final Document eventTemplateDocument = HTMLDocParser
                                .getDocument(RBGet.getGlobalConfigKey("PAGEFILES") + SUBSCRIBER_EMAIL_PLACE);
                        final String eventTemplate = HTMLDocParser
                                .convertNodeToHtml(HTMLDocParser.$("content", eventTemplateDocument));

                        for (int i = 0; i < referralArray.length(); i++) {

                            final JSONObject referral = referralArray.getJSONObject(i);
                            referral.getJSONObject("venue").getJSONObject("location").getDouble("lng");
                            referral.getJSONObject("venue").getJSONObject("location").getDouble("lat");
                            final String eventName = referral.getJSONObject("venue").getString("name");
                            final String eventUrl = referral.getJSONObject("venue").optString("url");
                            final String eventVenue = referral.getJSONObject("venue").getJSONObject("location")
                                    .getString("address");
                            Loggers.debug("Event name:" + eventName);
                            eventList
                                    .append(eventTemplate
                                            .replace("_name_link_",
                                                    !(("" + eventUrl).isEmpty()) ? eventUrl
                                                            : ("https://www.google.com/search?q=" + eventName
                                                                    .replaceAll(" ", "+").replaceAll("-", "+")))
                                            .replace("_place_link_",
                                                    "https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=600x600&markers=color:blue%7Clabel:S%7C"
                                                            + _read.getLatitude().toString() + ","
                                                            + _read.getLongitude().toString())
                                            .replace("_name_", eventName).replace("_place_", eventVenue)
                                            .replace("_date_", eventName));
                        }
                    } catch (final Throwable t) {
                        Loggers.error("Error appending Foursquare data to Geohash Subscriber", t);
                    }
                }

                final String template = HTMLDocParser
                        .getDocumentAsString(RBGet.getGlobalConfigKey("PAGEFILES") + EMAIL_FRAME);
                final Document email = HTMLDocParser
                        .getDocument(RBGet.getGlobalConfigKey("PAGEFILES") + SUBSCRIBER_EMAIL);
                final String _content = HTMLDocParser.convertNodeToHtml(HTMLDocParser.$("content", email));
                final Parameter _unsubscribeLink = new Parameter("http://www.ilikeplaces.com/unsubscribe/")
                        .append(Unsubscribe.TYPE, Unsubscribe.Type.GeohashSubscribe.name(), true)
                        .append(Unsubscribe.VALUE, rowKey);
                final String finalEmail = template.replace("_FrameContent_",
                        _content.replace(" ___||_", eventList.toString()).replace("_unsubscribe_link_",
                                _unsubscribeLink.get()));
                Loggers.debug("Final email:" + finalEmail);
                sendMailLocal.sendAsHTML(_read.getEmailId().toString(), "Thank God it's Friday!", finalEmail);
            }

        }

        _geohashSubscriberHBaseCrudService.scan(new GeohashSubscriber(), _scanner);
    }

    Loggers.debug("Completed scanner");

}