ERROR用于Alchemy api text / TextGetCombinedData的invalid-api-key PHP / CURL

时间:2016-07-13 17:07:48

标签: php curl text-extraction alchemyapi alchemy

我收到ERROR无效密钥

cURL / php代码:

 $request = "https://gateway-a.watsonplatform.net/calls/url/URLGetAuthors?apikey=$alchemyapikey&url=www.ibm.com";
    //echo $request;
    $curl = curl_init($request);
   $alchemydata = array
      'apikey' => $alchemyapikey,
      'text' => strip_tags($result),
      'outputMode' => 'json',
      'extract'=>'entities,keywords',
      'url'=>'https://www.ibm.com/us-en/',
    );

    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $alchemydata);
    curl_setopt($curl, CURLOPT_URL, "https://gateway-a.watsonplatform.net/calls/text/TextGetCombinedData");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($curl);
    if ($result === FALSE) {
        die("Curl failed: " . curL_error($curl));
    }

    curl_close($curl);

如果我错过了什么,请告诉我。

谢谢 巴斯卡尔

1 个答案:

答案 0 :(得分:0)

我想你错过了(

START TRANSACTION;
INSERT INTO users (username,email,password) VALUES ('batman','0','imtheonlytruehero');

if(affected_rows > 0) {
   $username = true;
   UPDATE users SET email='batman@heroes.com' WHERE username='batman';
   if(affected_rows > 0) {
      $email = true;
      $registration = true;
      COMMIT;
   }
   else {
      $email = false;
      $registration = true;
      ROLLBACK;
   }
}
else {
   $username = false;
   $email = null;
   $registration = false;
   ROLLBACK;
}