UBER Ride Reminder Api响应403禁止回应

时间:2017-04-06 07:52:03

标签: objective-c macos cocoa-touch uber-api

我正在研究UBER骑行提醒api.i我正在尝试使用我的server_token.passing必需参数发布乘车提醒,但作为回应我得到403禁止响应。我的http请求如下。

  NSDictionary *event=@{
                          @"time":event_time,
                          @"name":event_name
                          };
    NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
     [params setValue:reminder.reminder_time forKey:@"reminder_time"];
     [params setValue:reminder.phone_number forKey:@"phone_number"];

     [params setValue:event forKey:@"event"];



    NSString *url=@"https://api.uber.com/v1.2/reminders?server_token=***our server token***";

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
       [request setHTTPMethod:@"POST"];

    NSError *error=nil;
        request.HTTPBody = [NSJSONSerialization dataWithJSONObject:params options:0 error:&error];
    NSURLResponse *response = nil;
    [request addValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];


    NSData *authData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];


    if(!error && authData!=NULL)
    {
        NSError *jsonError = nil;
        NSDictionary *authDictionary = [NSJSONSerialization JSONObjectWithData:authData options:0 error:&jsonError];
        if(!jsonError && authDictionary !=nil)
        {

            NSLog(@"got respose");
        }
        else
        {
            NSLog(@"Error retrieving access token %@", jsonError);
        }
    }
    else
    {
        NSLog(@"Error in sending request for access token %@", error);
    }

和我从中得到的响应对象如下

<NSHTTPURLResponse: 0x600000029100> { URL: https://api.uber.com/v1.2/reminders?server_token=wMV7Y-ssag45YXzyTYZnYD7lCDNiBBKaG6Botcv7 } { status code: 403, headers {
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "application/json";
    Date = "Thu, 06 Apr 2017 07:39:50 GMT";
    Server = nginx;
    "Strict-Transport-Security" = "max-age=604800";
    "Transfer-Encoding" = Identity;
    "X-Content-Type-Options" = nosniff;
    "X-Uber-App" = "uberex-nonsandbox, optimus, migrator-uberex-optimus";
    "X-XSS-Protection" = "1; mode=block";
} }

和json响应是这个

    {
        code = forbidden;
        message = Forbidden;
    }

0 个答案:

没有答案