Curl Unirest请求-错误“;无效API“;

Curl Unirest请求-错误“;无效API“;,curl,cakephp,unirest,Curl,Cakephp,Unirest,我不熟悉curl和request,目前我正在尝试使用Unirest请求从站点获取一些内容,但我遇到了一个问题。 (如果重要的话,我使用的是cakePHP 2.9.5) 这是我的要求: public function getsuggestions($word, $someData) { if(!empty($word) && $word != '') { $data = $this->find('all', array(

我不熟悉curl和request,目前我正在尝试使用Unirest请求从站点获取一些内容,但我遇到了一个问题。 (如果重要的话,我使用的是cakePHP 2.9.5)

这是我的要求:

public function getsuggestions($word, $someData) {
        if(!empty($word) && $word != '') {
            $data = $this->find('all', array(
                'conditions' => array('Keyword.mot_saisi' => $word)
            ));
            if(!empty($data)) {
                $motcles = split(",",$data['0']['Keyword']['resultat'],11);
                $motcles['10'] = $word;
                return $motcles;
            }
            else { //We don't have the word in DB yet

                $country = $someData['Site']['pays'];
                $language = $someData['Site']['langue'];
                $url = 'https://ciokan-keyword-suggestion-v1.p.mashape.com/api/keyword/suggest/';
                $key = 'AKey'; //Can't share this
                require_once 'vendors\autoload.php';
                require_once 'vendors\mashape\unirest-php\src\Unirest.php';
                Unirest\Request::verifyPeer(false);
                $content = Unirest\Request::post($url,
                    array(
                        "X-Mashape-Key" => $key,
                        "Content-Type" => "application/x-www-form-urlencoded",
                        "Accept" => "application/json"
                    ),
                    array(
                        "country"   => $country,
                        "keyword"   => $word,
                        "language"  => $language,
                        "source"    => "google"
                    )
                );
                if(!empty($content)) {
                    debug($content); //Here is what is showing me an error
                    $decoded = json_decode($content,true);
                    debug($decoded);
                    $listWords = $decoded['results']['0'];
                    for ($i=1; $i < $decoded['total']['0']; $i++) { 
                        $listWords = $listWords.','.$decoded['results'][$i];
                    }
                    //Adding the answer in the DB
                    $data = array(
                        'id' => '',
                        'mot_saisi' => $word,
                        'resultat' => $listWords
                    );
                    if($this->save($data)) {
                        echo "Saved successfully";
                        $listWordsSplitted = split(",",$listWords,11);
                        $listWordsSplitted['10'] = $word;
                        return $listWordsSplitted;
                    }
                    else {
                        echo "Saving failed";
                    }
                }
            }
            //curl_close($ch);
        }
    }
我在任何地方都找不到这个问题的具体答案。 这是什么意思?有办法解决这个问题吗?

找到原因, 这只是因为我想从获取信息的网站删除了他的API

不需要更多的答案:)

object(Unirest\Response) {
    code => (int) 403
    raw_body => '{"message":"Invalid API"}'
    body => object(stdClass) {
        message => 'Invalid API'
    }
    headers => array(
        (int) 0 => 'HTTP/1.1 403 Forbidden',
        'Content-Type' => 'application/json',
        'Date' => 'Tue, 22 May 2018 06:58:21 GMT',
        'Server' => 'Mashape/5.0.6',
        'X-Mashape-Proxy-Response' => 'true',
        'Content-Length' => '25',
        'Connection' => 'keep-alive'
    )
}