Reputation: 309
I am building an instagram app in which i will be showing the pics of target user which the user will write. Is it possible to follow the person from my app??
I used this code to like a pic in instagram.
try {
URL url = new URL(API_URL + "/media/" + instapostid + "/likes?access_token=" + accessToken);
Log.d(TAG, "Opening URL " + url.toString());
HttpURLConnection urlConnection;
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.connect();
where API_URL is
private static final String API_URL = "https://api.instagram.com/v1";
Upvotes: 2
Views: 4107
Reputation: 319
Try This :
TextView txtFollow = (TextView) findViewById(R.id.txtFollow);
txtFollow.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Uri uri = Uri.parse("http://instagram.com/_u/URL");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
likeIng.setPackage("com.instagram.android");
try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/URL")));
}
}
});
Upvotes: 2
Reputation: 46856
Did you look in the Instagram API Docs?
This seems like what you are looking for:
https://api.instagram.com/v1/users/[user-id]/relationship?access_token=[ACCESS-TOKEN]
Modify the relationship between the current user and the target user.
PARAMETERS:
ACCESS_TOKEN A valid access token.
ACTION One of: follow/unfollow/block/unblock/approve/deny.
So if you are logged in you should be able to send a POST to this url giving a target user-id an access-token and an action parameter of "follow"
Upvotes: 2