123456789101112131415161718192021222324252627282930313233 |
- <?php
- /**
- * Created by PhpStorm.
- * User: ASUS
- * Date: 2018/7/18
- * Time: 10:53
- */
- namespace Jobs\Model\Test;
- class K3Curl
- {
- public static function MyCurlPost($url, $post_content, $cookie_jar, $isLogin)
- {
- $ch = curl_init($url);
- $this_header = array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($post_content)
- );
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
- curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- if ($isLogin) {
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
- } else {
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
- }
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- }
|