我需要将此 cURL 命令翻译成 PHP cURL 代码:
> curl --get 'https://api.twitter.com/1/followers/ids.json' --data > 'cursor=-1&screen_name=somename' --header 'Authorization: OAuth > oauth_consumer_key="key", oauth_nonce="nonce", > oauth_signature="signature", oauth_signature_method="HMAC-SHA1", > oauth_timestamp="timestamp", oauth_token="token", oauth_version="1.0"' > --verbose
我已经尝试过了,但它似乎不起作用:
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: OAuth oauth_consumer_key="key", oauth_nonce="nonce", oauth_signature="signature", oauth_signature_method="HMAC-SHA1", oauth_timestamp="timestamp", oauth_token="token", oauth_version="1.0"'));
> curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
> curl_setopt($ch, CURLOPT_VERBOSE, 1);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_HTTPGET, 1);
> curl_setopt($ch, CURLOPT_URL, 'https://api.twitter.com/1/users/show.json?cursor=-1&screen_name=somename');
> $page = curl_exec($ch);
> curl_close($ch);
我得到的错误
SSL证书问题,验证CA证书是否OK。详细信息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败
但是它适用于标准 curl 命令