【问题标题】:How can we Follow a person on instagram from our app?我们如何通过我们的应用在 Instagram 上关注一个人?
【发布时间】:2013-05-22 13:13:26
【问题描述】:

我正在构建一个 instagram 应用程序,我将在其中显示用户将写的目标用户的照片。是否可以通过我的应用关注此人??

我用这个代码点赞了 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();

API_URL 在哪里

private static final String API_URL = "https://api.instagram.com/v1";

【问题讨论】:

    标签: android instagram


    【解决方案1】:

    您查看过 Instagram API 文档吗?

    这似乎是您正在寻找的:

    https://api.instagram.com/v1/users/[user-id]/relationship?access_token=[ACCESS-TOKEN]
    

    修改当前用户与目标用户的关系。

    PARAMETERS:
    ACCESS_TOKEN    A valid access token.
    ACTION  One of: follow/unfollow/block/unblock/approve/deny.
    

    因此,如果您已登录,您应该能够向此 url 发送 POST,为目标用户 ID 提供访问令牌和“follow”操作参数

    See this page for more

    【讨论】:

    • 但我无法给出行动=关注,我应该如何发送??
    • 作为您发布请求的参数。
    • 我是android编程新手,请问您能告诉我如何发送参数吗??
    • See examples here 查看 POST 示例并将 url 和参数更改为您用于 instagram 的。
    • 非常感谢......你也能回答这个问题吗? stackoverflow.com/questions/16559814/…
    【解决方案2】:

    试试这个:

    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")));
                        }
    
                    }
     });
    

    【讨论】:

    • 这只是一个意图,问题是如何使用 Instagram API 进行关注
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-14
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-19
    • 1970-01-01
    相关资源
    最近更新 更多