这是我的代码:
require_once('api/TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "xxxxxxx",
'oauth_access_token_secret' => "xxxxxx",
'consumer_key' => " xxxxxxxx",
'consumer_secret' => "xxxxxxxx"
);
$url = 'https://twitter.com/myuser';
$requestMethod = 'POST';
$postfields = array(
'screen_name' => 'usernameToBlock',
'skip_status' => '1'
);
$twitter = new TwitterAPIExchange($settings);
var_dump($twitter->buildOauth($url, $requestMethod)->setPostfields($postfields)->performRequest());
var_dump的结果为空或什么都没有。我做错了什么?
这是perfomRequest函数:$ json它总是为null。有什么想法吗?
public function performRequest($return = true, $curlOptions = array()){
if (!is_bool($return)) {
throw new Exception('performRequest parameter must be true or false');
}
$header = array($this->buildAuthorizationHeader($this->oauth), 'Expect:');
$getfield = $this->getGetfield();
$postfields = $this->getPostfields();
$options = array(
CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => false
) + $curlOptions;
if (!is_null($postfields)) {
$options[CURLOPT_POSTFIELDS] = http_build_query($postfields);
}
else{
if ($getfield !== '')
{
$options[CURLOPT_URL] .= $getfield;
}
}
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
if (($error = curl_error($feed)) !== '')
{
curl_close($feed);
throw new \Exception($error);
}
curl_close($feed);
return $json;
}
我添加了这个:CURLOPT_SSL_VERIFYPEER =>我的功能是假的。我在论坛中看到解决了这个问题,但在我的情况下没有。可以有人帮助我吗?