Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Instagram API返回“;此请求需要scope=likes";_Ios_Swift_Instagram - Fatal编程技术网

Ios Instagram API返回“;此请求需要scope=likes";

Ios Instagram API返回“;此请求需要scope=likes";,ios,swift,instagram,Ios,Swift,Instagram,我正在使用Instagram登录。我的所有方法都能正常工作,但对于like media post,我遇到了一个错误:“此请求需要scope=likes” 在我的auth init中,我有: oauthswift!.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/instagram")!, scope: "likes", state:state, success: { creden

我正在使用Instagram登录。我的所有方法都能正常工作,但对于like media post,我遇到了一个错误:
“此请求需要scope=likes”

在我的auth init中,我有:

 oauthswift!.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/instagram")!, scope: "likes", state:state, success: {
            credential, response in

}, failure: {(error:NSError!) -> Void in
        //println(error.localizedDescription)
})
我的媒体查询如下所示:

 let url :String = "https://api.instagram.com/v1/media/MY_MEDIA_ID/likes?access_token=\(MY_ACCESS_TOKEN)"
 oauthswift!.client.post(url, parameters: parameters,
            success: {
                data, response in
 }, failure: {(error:NSError!) -> Void in
        println(error)
 })
"https://api.instagram.com/v1/media/\(MY_MEDIA_ID)/likes?access_token=\(MY_ACCESS_TOKEN)"

我遗漏了什么?

您必须将
媒体id
放在您硬编码字符串
我的媒体id
的URL中

我猜您的代码中有一个输入错误,所以应该是这样的:

 let url :String = "https://api.instagram.com/v1/media/MY_MEDIA_ID/likes?access_token=\(MY_ACCESS_TOKEN)"
 oauthswift!.client.post(url, parameters: parameters,
            success: {
                data, response in
 }, failure: {(error:NSError!) -> Void in
        println(error)
 })
"https://api.instagram.com/v1/media/\(MY_MEDIA_ID)/likes?access_token=\(MY_ACCESS_TOKEN)"
编辑:


根据网站的链接,POST的URL是
https://api.instagram.com/v1/media/{media id}/likes
,您发布的是用于GET。尝试只调用GET

您必须将
媒体id
放在URL中,其中包含硬编码字符串
我的媒体id

我猜您的代码中有一个输入错误,所以应该是这样的:

 let url :String = "https://api.instagram.com/v1/media/MY_MEDIA_ID/likes?access_token=\(MY_ACCESS_TOKEN)"
 oauthswift!.client.post(url, parameters: parameters,
            success: {
                data, response in
 }, failure: {(error:NSError!) -> Void in
        println(error)
 })
"https://api.instagram.com/v1/media/\(MY_MEDIA_ID)/likes?access_token=\(MY_ACCESS_TOKEN)"
编辑:


根据网站的链接,POST的URL是
https://api.instagram.com/v1/media/{media id}/likes
,您发布的是用于GET。试着只调用GET

它在我的项目中不是硬编码的。我在instagram api simulator中使用了相同的url,因此我的url是validWell,发送字符串my_MEDIA_ID看起来很可疑,你是否用\()将其包裹起来,就像你获得我的访问令牌一样?它是这样的:这是有效的url,我只是想指出,您在问题中发布的URL很可能无效,因为“MY_MEDIA_ID”是硬编码的,并且没有提取名为MY_MEDIA_ID的变量的内容。这就是为什么您不断收到
“此请求需要scope=likes”
。仔细阅读我想告诉你的内容并阅读文档。这是-URL上的第二个方法是
https://api.instagram.com/v1/media/{media id}/likes
,您需要填写表单才能访问,并且必须将访问令牌放在参数中,而不是URL中。在我的项目中它不是硬编码的。我在instagram api simulator中使用了相同的url,因此我的url是validWell,发送字符串my_MEDIA_ID看起来很可疑,你是否用\()将其包裹起来,就像你获得我的访问令牌一样?它是这样的:这是有效的url,我只是想指出,您在问题中发布的URL很可能无效,因为“MY_MEDIA_ID”是硬编码的,并且没有提取名为MY_MEDIA_ID的变量的内容。这就是为什么您不断收到
“此请求需要scope=likes”
。仔细阅读我想告诉你的内容并阅读文档。这是-URL上的第二个方法是
https://api.instagram.com/v1/media/{media id}/likes
,您需要填写表单才能访问,并且必须将访问令牌放在参数中,而不是URL中。在我的项目中它不是硬编码的。我在instagram api simulator中使用了相同的url,因此我的url是validWell,发送字符串my_MEDIA_ID看起来很可疑,你是否用\()将其包裹起来,就像你获得我的访问令牌一样?它是这样的:这是有效的url,我只是想指出,您在问题中发布的URL很可能无效,因为“MY_MEDIA_ID”是硬编码的,并且没有提取名为MY_MEDIA_ID的变量的内容。这就是为什么您不断收到
“此请求需要scope=likes”
。仔细阅读我想告诉你的内容并阅读文档。这是-URL上的第二个方法是
https://api.instagram.com/v1/media/{media id}/likes
,您需要填写表单才能访问,并且必须将访问令牌放在参数中,而不是URL中。