Skip to content

Instantly share code, notes, and snippets.

@daniellevass
Last active August 29, 2015 14:14
Show Gist options
  • Save daniellevass/baa6d04f88487dab291f to your computer and use it in GitHub Desktop.
Save daniellevass/baa6d04f88487dab291f to your computer and use it in GitHub Desktop.

compile 'com.squareup.okhttp:okhttp:2.2.0'

<uses-permission android:name="android.permission.INTERNET" />

private final OkHttpClient client= new OkHttpClient();

public void sendRequest() {
        Request request = new Request.Builder()
                .url("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22Bath%2C%20England%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys")
                .build();

        client.newCall(request).enqueue(new Callback() {

            @Override
            public void onFailure(Request request, IOException e) {

            }

            @Override public void onResponse(Response response) throws IOException {
                Log.d("DANIELLE", response.body().string());
            }
        });
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment