Tag Archives: instagram

Instagram API wrapper for Android

Synopsis

Instagram(IG) API wrapper for Android for handling an Instagram app lifecycle. Split into 2 sub-projects:

  • InstagramAuth Authentication library, based uppon Facebook for Android library.
  • restig A wrapper arround IG rest API calls. Based upon restFB.

Documentation

Currently short on documentation, will add more as time permits.

Examples

InstagramAuth

/**
 * Authorize a user in Instagram. Will show up the auth dialog and will
 * allow the user to enter his/her credentials.
*

* <strong> Pay attention</strong> Use the listener afterwards to save the
 * authentication token.
 *
 * @param listener
 * - A dialog listener that can react to various authentication
 * events. Cannot be null.
 * @param permissions
 * - Use various permissions. Can be empty but not null.
 * @param activity
 * - An activity that will be the parent of the dialog box.
 */
 public void authorize(final DialogListener listener,
 final Activity activity, final String... permissions) {
 InstagramModule module = new InstagramModule();
 final InstagramAuthDialog dialog = new InstagramAuthDialog(activity,
 listener, mAppId, permissions);
 dialog.setCancelable(false);
 dialog.show();
 }

public class InstagramModule implements
 DialogListener {
 @Override
 public void onComplete(final Bundle values) {
 String accessToken = values.getString("access_token");
 }

@Override
 public void onError(final DialogError error) {
 // Log error
 }

@Override
 public void onCancel() {
 // User canceled.
 }
 }
 ...
 authorize(new InstagramModule(), activity, "likes", "comments");

restig

InstagramClient userClient = new DefaultInstagramClient(appId, mAccessToken);
final String endPoint = format("media/%s/comments",
"1234");
final InstagramCollection comments = client
.fetchCollection(endPoint, Comment.class);

You can download the source from github

Advertisements

Leave a comment

Filed under API