【问题标题】:Yoda Speak Api. Is it the key or code?尤达说 Api。是钥匙还是密码?
【发布时间】:2015-04-02 00:32:43
【问题描述】:

我正在尝试使用 Yoda speak api。这是我的小提琴:

  • http://jsfiddle.net/Dansker/tdhnmmye/

    $.ajax({
        url: 'https://yoda.p.mashape.com/yoda', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
        type: 'GET', // The HTTP Method
        data: {sentence: $("#boxArea").val()}, // Additional parameters here
        datatype: 'json',
        success: function (data) {
            alert(data);
        },
        error: function (err) {
            alert(err);
        },
        beforeSend: function (xhr) {
            xhr.setRequestHeader("X-Mashape-Authorization", "<RvyROurVRvmshRzDcAtXABdytvkDp1MtroWjsnXo8Dcs9Dq6SB>"); // Enter here your Mashape key
        }
    });});});
    

我认为代码一切正常,但我不断收到 403 错误,说我的密钥不起作用。我一直在重置我的密钥,但它一直说它不起作用。是钥匙还是别的什么? “yoda speak”也会显示为警报吗?

【问题讨论】:

  • 从您的密钥中删除 运算符。还假设这是您的实际 mashape 密钥,您不想将其发布在这里供所有人查看。附带说明一下,我使用上述 API 已经有一段时间了。结合 Mashape 问题和实际的 API 端点停机时间,我遇到了重大问题,因此切换到 funtranslations.com/api/yoda,它的工作就像一个魅力。

标签: json api mashape


【解决方案1】:

只是猜测,但您是否尝试过删除外部尖括号?

尝试改变这个:

xhr.setRequestHeader("X-Mashape-Authorization", "<RvyROurVRvmshRzDcAtXABdytvkDp1MtroWjsnXo8Dcs9Dq6SB>");

到这里:

xhr.setRequestHeader("X-Mashape-Authorization", "RvyROurVRvmshRzDcAtXABdytvkDp1MtroWjsnXo8Dcs9Dq6SB");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-01
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多