2
curl -X POST -u "<application key>:<master secret>" \
-H "Content-Type: application/json" \
--data '{"device_tokens": ["<token>"], "aps": {"alert": "Hello!"}}' \
https://go.urbanairship.com/api/push/
我不明白如何將應用程序密鑰和主密鑰添加到標題中。這是我迄今爲止的代碼,如果這引發任何解決方案。如何使用ASIHTTPRequest來表示此CURL?
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"https://go.urbanairship.com/api/push/"]] autorelease];
[request setRequestMethod:@"POST"];
request.username = @"APPLICATION KEY";
request.password = @"MASTER SECRET";
[request setPostValue:@"MY DEVICE CODE TOKEN" forKey:@"device_tokens"];
[request setPostValue:@"hello" forKey:@"alert"];
[request setDelegate:self];
[request startSynchronous];
當我使用上面的代碼時,我收到「需要授權」的響應,所以我必須做錯了什麼。
希望我能+10這一個:d – rahzark