Created
September 30, 2015 10:36
-
-
Save samma835/52f93c4d9b93d29e1593 to your computer and use it in GitHub Desktop.
douban oauth code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'POST': | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | |
curl_setopt($ch, CURLOPT_TIMEOUT, '10'); | |
$headers = array(); | |
$userAgents = array( | |
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6", | |
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)", | |
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)", | |
"Opera/9.20 (Windows NT 6.0; U; en)", | |
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50", | |
"Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.02 [en]", | |
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; fr; rv:1.7) Gecko/20040624 Firefox/0.9", | |
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/48 (like Gecko) Safari/48" | |
); | |
$random = rand(0, count($userAgents) - 1); | |
$headers[] = 'User-Agent: ' . $userAgents[$random]; | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
$return = $this->parse_response($response); | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment