Skip to content

Instantly share code, notes, and snippets.

@alex-shpak
alex-shpak / Interceptor.java
Last active June 14, 2024 02:40
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@kristopherjohnson
kristopherjohnson / gcmpush.php
Last active April 7, 2016 11:22
Simple PHP script to send a push notification to an Android device via GCM
#!/usr/bin/php
<?php
// This script sends a Google Cloud Messaging message to an Android smartphone.
// It is intended to mimic what the server does.
//
// To use it, set the API access key and the registration ID ("device token")
// for the target device(s).
//
// Credit: http://stackoverflow.com/questions/22168819/android-test-push-notification-online