Skip to content

Instantly share code, notes, and snippets.

@skiph
Last active May 4, 2017 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skiph/0fa5a075603bb5112958afaf6e14a91c to your computer and use it in GitHub Desktop.
Save skiph/0fa5a075603bb5112958afaf6e14a91c to your computer and use it in GitHub Desktop.
API Key Proxy - modified photo requester
public class PhotoRequester {
// ...
public void getPhoto() throws IOException {
// grab the current calendar date and back up one day for next request
final String date = mDateFormat.format(mCalendar.getTime());
mCalendar.add(Calendar.DAY_OF_YEAR, -1);
// build and call the request
String urlRequest = mContext.getString(R.string.api_url) +
BASE_PATH + DATE_PARAMETER + date;
/* ************ REMOVE API_KEY FROM urlRequest *************
urlRequest += API_KEY_PARAMETER + mContext.getString(R.string.api_key);
*/
final Request request = new Request.Builder().url(urlRequest).build();
mLoadingData = true;
mClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// ...
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// ...
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment