API 密钥无效 Yandex 翻译

API key is invalid Yandex Translate

我使用 Yandex-transleyt,并根据要求收到答复 "API key is invalid." 它刚刚收到密钥。关于查询的格式,这个题目没有帮助(Yandex API Translator error - 401 API key is invalid)。 请求格式作为指导:https://tech.yandex.com/translate/doc/dg/reference/translate-docpage/

我的要求:

var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?";
var keyAPI = "trnsl.1.1.20161125T152027Z.65e73e18a60f3051.7764a7a11754995544ad557501df9e14abbfb6e0";

var params = "key=" + keyAPI + "&text=" + textApi + "&lang=" + langApi;
var vm = this;

$http({
    url: url,
    method: 'POST',
    params: params
});

可能是请求参数错误?

完整代码here或此处:

 var app = angular.module('jsbin', []);

app.controller('DemoCtrl', function($scope, $http) {

 $scope.SendData = function() {
  // тут данные
  var textApi = 'Hello';
  var langApi = 'en-ru';
  var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?";
  var keyAPI = "trnsl.1.1.20161125T152027Z.65e73e18a60f3051.7764a7a11754995544ad557501df9e14abbfb6e0";

  var params = "key=" + keyAPI + "&text=" + textApi + "&lang=" + langApi;
  var vm = this;

  $http({
    url: url,
    method: 'POST',
    params: params
   })
   .success(function(data, headers, status, config) {
    $scope.PostDataResponse = data;
    vm.data = data;
    console.log(data);
   })
   .error(function(data, headers, status, config) {
    $scope.ResponseDetails = "Data: " + data +
     "<hr />status: " + status +
     "<hr />config: " + config;
    console.log("error1");
    console.log(data);
    console.log(status);
    console.log(config);
   });
 };
});
<!DOCTYPE html>
<html>
<head>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
  <meta charset="utf-8">
  <title>Angular JS</title>
   </head>
<body ng-app="jsbin">
  <div ng-controller="DemoCtrl as vm">
    
          <button ng-click="SendData()">Send</button>
    <br>
      Data:  {{PostDataResponse}}<br>
    {{vm.data}}
    {{vm.PostDataResponse}}
   Data:  {{scope.PostDataResponse}}
    {{vm.data}}
  </div>
  </body>
  </html>

现在可以了!谢谢大家。

var app = angular.module('jsbin', []);

app.controller('DemoCtrl',function($scope, $http){
    
    $scope.SendData = function () {
          // тут данные
      var textApi='Hello';
      var langApi='en-ru';
       var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?";
    var  keyAPI ="trnsl.1.1.20161125T152027Z.65e73e18a60f3051.7764a7a11754995544ad557501df9e14abbfb6e0";
  
       params ='key='+keyAPI+'&text='+textApi+'&lang='+langApi;
    var vm = this;
       $scope.method = 'POST';
    $scope.url = 'https://translate.yandex.net/api/v1.5/tr.json/translate?';  
      
     $http({
   url: url,
   method:"POST",
   params:{key:keyAPI,text:textApi,lang:langApi},
})
.success(function(data,headers,status,config){
  $scope.PostDataResponse = data;
  vm.data = data;
  console.log(data);
 })
.error(function(data,headers,status,config){
 $scope.ResponseDetails = "Data: " + data +
                "<hr />status: " + status +
                     "<hr />config: " + config;
       console.log("error1");
       console.log(data);
        console.log(status);
       console.log(config)
     }
)
}
}
);
<!DOCTYPE html>
<html>
<head>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
  <meta charset="utf-8">
  <title>Angular JS</title>
   </head>
<body ng-app="jsbin">
  <div ng-controller="DemoCtrl as vm">
    
          <button ng-click="SendData()">Send</button>
    <br>
      Data:  {{PostDataResponse}}<br>
    {{vm.data}}
    {{vm.PostDataResponse}}
   Data:  {{scope.PostDataResponse}}
    {{vm.data}}
  </div>
  </body>
  </html>