1n9i9c7om / ClashOfClans-API-PHP

PHP wrapper for SuperCell's official ClashOfClans API.
MIT License
34 stars 13 forks source link

Non-Object #13

Closed RepeaterCreeper closed 8 years ago

RepeaterCreeper commented 8 years ago

Everything I do is being met with Notice: Trying to get property of non-object in C:\xampp\htdocs\Clan Link\requests\ClashAPI\Clan.class.php on line 115

image

Checked:

As previously stated the CODE is the exact replica of the "Examples: clanInformation.php" even the location of the API.class.php is the same.

1n9i9c7om commented 8 years ago

In API.class.php, add a var_dump to sendRequest (line 24), like this:

    protected function sendRequest($url)
    {
        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'authorization: Bearer '.$this->_apiKey // 
        ));
        $output = curl_exec($ch);
        curl_close($ch); 
        var_dump($output); //this is the new addition
        return $output;
    }

This should allow better debugging. What is it showing now?

RepeaterCreeper commented 8 years ago

image

bool(false) bool(false)

RepeaterCreeper commented 8 years ago

Never mind I figured it out. I remembered that the API Wrapper I used didn't work either until my friend suggested I add this curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);. Finally it works. :)