From d9a98a7baf45b9cb36d03155271676be69d767ba Mon Sep 17 00:00:00 2001 From: mgp25 Date: Wed, 9 Sep 2015 16:30:52 +0200 Subject: [PATCH] Fixes #193 --- src/snapchat_agent.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/snapchat_agent.php b/src/snapchat_agent.php index 004d40b..4b52d86 100644 --- a/src/snapchat_agent.php +++ b/src/snapchat_agent.php @@ -457,21 +457,21 @@ public function post($endpoint, $data, $params, $multipart = FALSE, $debug = FAL exit(); } } + } - if($endpoint == "/bq/get_captcha") + if($endpoint == "/bq/get_captcha") + { + file_put_contents(__DIR__."/captcha.zip", $result); + rewind($headerBuff); + $headers = stream_get_contents($headerBuff); + if(preg_match('/^Content-Disposition: .*?filename=(?[^\s]+|\x22[^\x22]+\x22)\x3B?.*$/m', $headers, $matches)) { - file_put_contents(__DIR__."/captcha.zip", $result); - rewind($headerBuff); - $headers = stream_get_contents($headerBuff); - if(preg_match('/^Content-Disposition: .*?filename=(?[^\s]+|\x22[^\x22]+\x22)\x3B?.*$/m', $headers, $matches)) - { - $filename = trim($matches['f'],' ";'); - rename(__DIR__."/captcha.zip", __DIR__."/{$filename}"); - return $filename; - } - fclose($headerBuff); - return "captcha.zip"; + $filename = trim($matches['f'],' ";'); + rename(__DIR__."/captcha.zip", __DIR__."/{$filename}"); + return $filename; } + fclose($headerBuff); + return "captcha.zip"; } $gi = curl_getinfo($ch);