【问题标题】:modify relationship in instagram by using oriceon laravel 5 oauth wrapper使用 oriceon laravel 5 oauth 包装器修改 instagram 中的关系
【发布时间】:2016-01-27 09:30:56
【问题描述】:

我正在使用oriceon/oauth-5-laravel 连接 instagram。我通过此请求进行了身份验证并获得了我的姓名和 ID

$result = json_decode($instagramService->request('users/self'), true); 现在我想通过使用这个oriceon/oauth-5-laravel 来关注一个人。 我如何使用这个来发布关注一个人的请求。

**注意:**不要参考 instagram 开发者页面。我对其进行了很多修改。但我无法为 instagram 发布 ORICEON/laravel oauth 包装器的发布请求。

提前帮助 ME.TYSM

【问题讨论】:

    标签: api oauth laravel-5 instagram-api


    【解决方案1】:

    试试这个。将此方法复制到您的控制器并进行正确的路由。

    public function followWithInstagram(Request $request)
        {
            $instagram_id='id of the user that you want to follow';
            $code = $request->get('code');
            $instagramService = \OAuth::consumer('Instagram');
            if ( ! is_null($code))
            {
                $state = isset($_GET['state']) ? $_GET['state'] : null;
                $instagramService->requestAccessToken($code, $state);
                $linkData = [
                  'action' =>'follow',
                              ];
                $result =json_decode($instagramService->request('https://api.instagram.com/v1/users/'.$instagram_id.'/relationship','POST',$linkData),true);
                if(!$result){
                    return ("Failed");
                }
                else {
                    return ("SUCCESS");         
                }
            } else {
                $url = $instagramService->getAuthorizationUri();
                return redirect((string)$url);
            } 
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 1970-01-01
      • 2017-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-21
      相关资源
      最近更新 更多