0

我正在尝试将有效负载发送到 Xtify 2.0 push api。

我尝试使用以下代码从我的 iOS 应用程序中进行:

- (void)sendPushToXids:(NSMutableArray *)xids {
        ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:xtifyPushUrl]];
        req.requestMethod = @"POST";

        [req setPostValue:xAppKey forKey:@"appKey"];
        [req setPostValue:xApiKey forKey:@"apiKey"];
        [req setPostValue:xids forKey:@"xids"];

        NSMutableDictionary *contentDict = [[NSMutableDictionary alloc] init];
        [contentDict setObject:@"This is a message" forKey:@"message"];
        [contentDict setObject:@"default.caf" forKey:@"sound"];

        [req setPostValue:contentDict forKey:@"content"];

        req.delegate = self;
        [req startAsynchronous];
    }

其中 xids 是一个包含一项的 NSMutableArray。

我也尝试使用 Firefox 插件 REST 客户端使用此代码:标题:

Content-type: application/json

数据:

{
    "apiKey": "myapikey",
    "appKey": "myappkey",
    "xids": ["500865a987242167c69b4e6c"], 
    "content": {
        "subject": "Greetings Earthlings",
        "message": "Take me to your leader"
    }
}

(我的“myapikey”和“myappkey”被我的应用程序密钥替换)

使用 POST 方法和 url “http://api.xtify.com/2.0/push”

在这两种情况下,Xtify 都会响应:

HTTP Status 415 - Unsupported Media Type

type Status report

message Unsupported Media Type

description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Unsupported Media Type).

我究竟做错了什么?

4

1 回答 1

2

该消息意味着您的 API 密钥不正确或已过期。确保在 Xtify 控制台中创建高级密钥。

于 2012-07-20T17:47:13.977 回答