为了使已签名的API调用Instagram post方法来跟踪用户,如用户的图像等,用户的跟踪时间限制在每小时20次。但是,如果我们进行签名的API调用,那么用户可以进行60跟踪每小时。但我的问题是如何进行签名API调用。?
我在Instagram http://instagram.com/developer/restrict-api-requests/上尝试了这种方法,并使强制的标头使.and发送的X-Insta-Forwarded-For标头字段具有有效的Id。但到了20岁以后,它仍然显示出极限误差。有谁能帮我打签名的API电话吗?
提前谢谢。
发布于 2014-10-15 04:26:35
在搜索完这些东西之后,我用这个解决了我的问题,让我的应用程序签了名:
要对Instagram进行有签名的API调用,用户需要在他们的insta中检查两个复选框。管理客户。并且必须跟随隐式OAuth格兰特流。
对于所有跟随/类似post类型的请求,用户需要添加一个标头: of类型为
X-Insta-Forwarded-For -> [IP information]|[Signature]
IP应该是由应用程序的负载均衡器检测到的客户端的远程IP;签名是,使用SHA256应用HMAC,并在其中附加签名的十六进制表示。在IP address上作为数据使用您的clientSecret作为键。然后使用管道|连接IP信息和签名,并将其设置为标头字段的值。
我使用了以下代码来生成签名:
-(NSString *)signWithKey:(NSString *)key usingData:(NSString *)data
{
const char *cKey = [key cStringUsingEncoding:NSASCIIStringEncoding];
const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC length:sizeof(cHMAC)];
return [[HMAC.description stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]] stringByReplacingOccurrencesOfString:@" " withString:@""];
}
-(NSString*)getheaderData
{
NSString *ipString = [self fetchMyIP];
NSString *signature = [self signWithKey:kClientSecret usingData:ipString];
}
To set header in iOS: [request setValue:[self getheaderData] forHTTPHeaderField:@"X-Insta-Forwarded-For"];因此,API调用将作为签名的API调用发送。
https://stackoverflow.com/questions/26333176
复制相似问题