0
發佈採購信息我在編程的新手,尤其是在網絡側。所以現在我正在創建與Instagram互動的應用程序。在我的項目中,我使用AFNetworking。我在這裏看到了他們的文檔和許多例子。我不明白如何獲得POST API請求到Instagram API。請ü可以給我真正的代碼示例或東西在那裏我可以瞭解如何執行此操作?請幫忙。我試圖提出這樣的要求,它沒有提供任何錯誤,也沒有任何迴應。它提供了什麼:(與AFNetworking
(IBAction)doRequest:(id)sender{
NSURL *baseURL = [NSURL URLWithString:@"http://api.instagram.com/"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
[httpClient defaultValueForHeader:@"Accept"];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
user_token, @"access_token",
nil];
[httpClient postPath:@"/feed" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
// reponseObject will hold the data returned by the server.
NSLog(@"data: %@", responseObject);
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error retrieving data: %@", error);
}];
NSLog(@"click!!");
}
非常感謝,弗洛裏安!當我接近我的Mac時,我會嘗試它。還有一兩件事:在請求參數「路徑」 - 是路徑設備上JSON或本地路徑? – pash3r
這是附加到你提供的AFHTTPClient基本URL路徑。例如,通過爲路徑指定「/ users/self/feed」,請求URL將爲「https:// api.instagram.com/users/self/feed」。 – florian
你是我的救命恩人!!!!!!!!!非常感謝你!!!! – pash3r