• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP http_parse_headers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中http_parse_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP http_parse_headers函数的具体用法?PHP http_parse_headers怎么用?PHP http_parse_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了http_parse_headers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: initialize

 function initialize()
 {
     if (!$this->fetched) {
         $config =& get_config();
         $assetUrl = $config['asset_service'] . $this->node['AssetID'];
         $curl = new Curl();
         $curl->create($assetUrl);
         $curl->option(CURLOPT_HEADER, true);
         $curl->option(CURLOPT_NOBODY, true);
         $response = $curl->execute();
         if ($response) {
             $headers = http_parse_headers($response);
             $this->size = $headers['Content-Length'];
             $this->contentType = $headers['Content-Type'];
             if (isset($headers['ETag'])) {
                 $this->etag = $headers['ETag'];
             } else {
                 if (isset($headers['Etag'])) {
                     $this->etag = $headers['Etag'];
                 } else {
                     $this->etag = '';
                 }
             }
         } else {
             log_message('error', "InventoryFile: Failed to fetch headers from {$assetUrl}");
         }
         $this->fetched = true;
     }
 }
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:29,代码来源:Class.InventoryFile.php


示例2: parseHeaders

 /**
  * if PECL_HTTP is not available use a fall back function
  *
  * thanks to [email protected]
  * http://php.net/manual/en/function.http-parse-headers.php#112986
  * @param string $raw_headers raw headers
  * @return array
  */
 private function parseHeaders($raw_headers)
 {
     if (function_exists('http_parse_headers')) {
         return http_parse_headers($raw_headers);
     } else {
         $key = '';
         $headers = array();
         foreach (explode("\n", $raw_headers) as $i => $h) {
             $h = explode(':', $h, 2);
             if (isset($h[1])) {
                 if (!isset($headers[$h[0]])) {
                     $headers[$h[0]] = trim($h[1]);
                 } elseif (is_array($headers[$h[0]])) {
                     $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
                 } else {
                     $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
                 }
                 $key = $h[0];
             } else {
                 if (substr($h[0], 0, 1) == "\t") {
                     $headers[$key] .= "\r\n\t" . trim($h[0]);
                 } elseif (!$key) {
                     $headers[0] = trim($h[0]);
                 }
             }
         }
         return $headers;
     }
 }
开发者ID:bamboodigital,项目名称:unirest-php,代码行数:37,代码来源:Response.php


示例3: parse_header_string

 /**
  * Parses a HTTP header string into an associative array
  *
  * @param   string   $header_string  Header string to parse
  * @return  HTTP_Header
  */
 public static function parse_header_string($header_string)
 {
     // If the PECL HTTP extension is loaded
     if (extension_loaded('http')) {
         // Use the fast method to parse header string
         return new HTTP_Header(http_parse_headers($header_string));
     }
     // Otherwise we use the slower PHP parsing
     $headers = array();
     // Match all HTTP headers
     if (preg_match_all('/(\\w[^\\s:]*):[ ]*([^\\r\\n]*(?:\\r\\n[ \\t][^\\r\\n]*)*)/', $header_string, $matches)) {
         // Parse each matched header
         foreach ($matches[0] as $key => $value) {
             // If the header has not already been set
             if (!isset($headers[$matches[1][$key]])) {
                 // Apply the header directly
                 $headers[$matches[1][$key]] = $matches[2][$key];
             } else {
                 // If the entry is an array
                 if (is_array($headers[$matches[1][$key]])) {
                     // Apply the new entry to the array
                     $headers[$matches[1][$key]][] = $matches[2][$key];
                 } else {
                     $headers[$matches[1][$key]] = array($headers[$matches[1][$key]], $matches[2][$key]);
                 }
             }
         }
     }
     // Return the headers
     return new HTTP_Header($headers);
 }
开发者ID:EhteshamMehmood,项目名称:BlogMVC,代码行数:37,代码来源:http.php


示例4: executeMultiRequest

 /**
  * Executes a curl request.
  *
  * @param  resource $request
  * @return \Frlnc\Slack\Contracts\Http\Response
  */
 public function executeMultiRequest($multiRequest, $singleRequests)
 {
     $responses = [];
     $infos = [];
     $active = null;
     do {
         $status = curl_multi_exec($multiRequest, $active);
         $infos[] = curl_multi_info_read($multiRequest);
     } while ($status === CURLM_CALL_MULTI_PERFORM || $active);
     foreach ($singleRequests as $index => $singleRequest) {
         $body = curl_multi_getcontent($singleRequest);
         curl_multi_remove_handle($multiRequest, $singleRequest);
         curl_close($singleRequest);
         $info = $infos[$index];
         $statusCode = $info['http_code'];
         $headers = $info['request_header'];
         if (function_exists('http_parse_headers')) {
             $headers = http_parse_headers($headers);
         } else {
             $header_text = substr($headers, 0, strpos($headers, "\r\n\r\n"));
             $headers = [];
             foreach (explode("\r\n", $header_text) as $i => $line) {
                 if ($i !== 0) {
                     list($key, $value) = explode(': ', $line);
                     $headers[$key] = $value;
                 }
             }
         }
         $responses[] = $this->factory->build($body, $headers, $statusCode);
     }
     curl_multi_close($multiRequest);
     return $responses;
 }
开发者ID:kapik,项目名称:alfred-slack,代码行数:39,代码来源:MultiCurlInteractor.php


示例5: parseHeaders

 /**
  * @param $raw
  * @return array
  */
 public static function parseHeaders($raw)
 {
     if (!$raw) {
         return [];
     }
     if (function_exists('http_parse_headers')) {
         return http_parse_headers($raw);
     }
     $headers = [];
     $key = '';
     foreach (explode("\n", $raw) as $h) {
         $h = explode(':', $h, 2);
         if (isset($h[1])) {
             if (!isset($headers[$h[0]])) {
                 $headers[$h[0]] = trim($h[1]);
             } elseif (is_array($headers[$h[0]])) {
                 $headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]);
             } else {
                 $headers[$h[0]] = array_merge(array($headers[$h[0]]), [trim($h[1])]);
             }
             $key = $h[0];
         } else {
             if (substr($h[0], 0, 1) == "\t") {
                 $headers[$key] .= "\r\n\t" . trim($h[0]);
             } elseif (!$key) {
                 $headers[0] = trim($h[0]);
             }
         }
     }
     return $headers;
 }
开发者ID:exaprint,项目名称:php-rest-eventbus,代码行数:35,代码来源:Helper.php


示例6: message

function message($cookie, $id, $subject = 'None', $body = 'None', $save = '../Private/mxcsrf.txt')
{
    $xcsrf = file_exists($save) ? file_get_contents($save) : '';
    $curl = curl_init('http://www.roblox.com/messages/send');
    $send = array('subject' => $subject, 'body' => $body, 'recipientid' => $id, 'cacheBuster' => time());
    curl_setopt_array($curl, array(CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array("X-CSRF-TOKEN: {$xcsrf}"), CURLOPT_POST => true, CURLOPT_POSTFIELDS => $send, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_RETURNTRANSFER => true));
    $response = curl_exec($curl);
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($responseCode != 200) {
        if ($responseCode == 403) {
            // 403 XCSRF Token Validation Failed
            $header = http_parse_headers(substr($response, 0, $headerSize));
            $xcsrf = $header['X-CSRF-TOKEN'];
            file_put_contents($save, $xcsrf);
            return message($cookie, $id, $subject, $body, $save);
        }
    }
    $json = json_decode(substr($response, $headerSize), true);
    if ($json['success']) {
        return "Sent message {$subject} to {$id}.";
    } else {
        $error = $json['shortMessage'];
        return "Error sending message {$subject} to {$id}: {$error}";
    }
}
开发者ID:TebbadRBLX,项目名称:Bots,代码行数:26,代码来源:message.php


示例7: loadFromURL

 protected function loadFromURL($url)
 {
     $image = file_get_contents($url);
     $headers = http_parse_headers(implode("\r\n", $http_response_header));
     $ext = array_search($headers['Content-Type'], $mimeExtensions);
     return array($image, $ext);
 }
开发者ID:anpone,项目名称:sitecake,代码行数:7,代码来源:ImageTool.php


示例8: execute

 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // add your code here
     $blogs = Doctrine::getTable('Blog');
     $blogs_to_process = $blogs->findByIsThumbnail(0);
     foreach ($blogs_to_process as $blog) {
         $thumbalizr_url = 'http://api.thumbalizr.com?';
         $params = array('url' => $blog->url, 'width' => 300);
         $api_url = $thumbalizr_url . http_build_query($params);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $api_url);
         curl_setopt($ch, CURLOPT_HEADER, true);
         curl_setopt($ch, CURLOPT_NOBODY, true);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $res = curl_exec($ch);
         curl_close($ch);
         $res_tab = http_parse_headers($res);
         if (!empty($res_tab['X-Thumbalizr-Status']) && $res_tab['X-Thumbalizr-Status'] == 'OK') {
             // Image is ready let's store the URL!
             $image_data = file_get_contents($api_url);
             $path = sfConfig::get('app_image_path');
             $url = sfConfig::get('app_image_url');
             $image_name = md5($blog->url);
             echo $path . $image_name . "\n";
             file_put_contents($path . $image_name . '.jpg', $image_data);
             $blog->thumbnail_url = $image_name . '.jpg';
             $blog->is_thumbnail = 1;
             $blog->save();
             // Send mail to notify the blo will get into the game!
             try {
                 // Create the mailer and message objects
                 //$mailer = new Swift(new Swift_Connection_NativeMail());
                 //$connection = new Swift_Connection_SMTP('smtp.free.fr');
                 $connection = new Swift_Connection_NativeMail();
                 $mailer = new Swift($connection);
                 $message = new Swift_Message('Welcome!');
                 // Render message parts
                 $mailContext = array('admin_hash' => $blog->getAdmin_hash(), 'blog_url' => $blog->getUrl());
                 $v = $this->getPartial('newBlogMailHtmlBody', $mailContext);
                 $htmlPart = new Swift_Message_Part($v, 'text/html');
                 $message->attach($htmlPart);
                 $message->attach(new Swift_Message_Part($this->getPartial('newBlogMailTextBody', $mailContext), 'text/plain'));
                 $mailTo = $blog->getEmail();
                 $mailFrom = sfConfig::get('app_mail_webmaster');
                 $mailer->send($message, $mailTo, $mailFrom);
                 $mailer->disconnect();
             } catch (Exception $e) {
                 $this->logMessage($e);
             }
         } else {
             //print_r($res_tab);
         }
     }
 }
开发者ID:nazab,项目名称:Blog-or-Not,代码行数:57,代码来源:blogThumbnailTask.class.php


示例9: header_fetch

function header_fetch($url, $check_against)
{
    $data = get_url($url, true);
    $headers = http_parse_headers($data);
    foreach ($headers as $key => $value) {
        if ($key == $check_against->header_option) {
            echo $key . ': ' . $value;
        }
    }
}
开发者ID:sous-studio,项目名称:CMSIdentifyFramework,代码行数:10,代码来源:header_fetch.php


示例10: getPingbackServerURL

 public static function getPingbackServerURL($url)
 {
     (new Chainable(new cURL($url)))->setopt(CURLOPT_HEADER, true)->setopt(CURLOPT_NOBODY, true)->setopt(CURLOPT_RETURNTRANSFER, true)->exec()->_get_return($curldata)->close();
     $headers = http_parse_headers($curldata);
     if (isset($headers['X-Pingback']) && !empty($headers['X-Pingback'])) {
         return $headers['X-Pingback'];
     }
     $response = file_get_contents($url);
     return preg_match(self::REGEXP_PINGBACK_LINK, $response, $match) ? $match[1] : false;
 }
开发者ID:jankal,项目名称:mvc,代码行数:10,代码来源:Utility.php


示例11: parseHeader

 function parseHeader($header)
 {
     $head = http_parse_headers($header);
     if ($head === false) {
         return false;
     } else {
         $head[0]['protocol'] = "HTTP/1.1";
         $head[0]['uri'] = $head["Request Url"];
         $head[0]['method'] = $head["Request Method"];
     }
     return $head;
 }
开发者ID:jasonshaw,项目名称:framework-1,代码行数:12,代码来源:ExtParser.php


示例12: getHeaders

 /**
  * Return the headers as associative array or return the given header.
  * @param string $key
  * @return string|string[]
  */
 public function getHeaders($key = null)
 {
     if (!$this->headers) {
         $this->headers = http_parse_headers($this->rawHeaders);
     }
     if ($key) {
         if (isset($this->headers[$key])) {
             return $this->headers[$key];
         }
     }
     return $this->headers;
 }
开发者ID:quazardous,项目名称:priceminister-ws,代码行数:17,代码来源:BasicResponse.php


示例13: updateRank

function updateRank($group, $userId, $rank, $cookie, $ranks, $roles, $rankLimit = 255, $save = '../Private/gxcsrf.txt')
{
    // OH MY GOD SO MANY ARGUMENTS!
    $xcsrf = file_exists($save) ? file_get_contents($save) : '';
    /* 
    		
    		If you want to increase performance do this:
    			Move the following line (currentRank) into the rankLimit if statement.
    			Change the success return to something simpler (does not return user's previous rank)
    	This doesn't actually slow it down that much at all, but when changing ranks **IN BULK** you will be making a lot of requests.
    */
    $currentRank = getRankInGroup($userId, $group);
    if ($rankLimit && $rankLimit < 255) {
        if ($rank > $rankLimit || $currentRank > $rankLimit) {
            // Check if the rank you are trying to change them to and their rank abide to the rank limit
            return "Settings restrict the system from changing any rank over {$rankLimit}.";
        }
    }
    $url = "http://www.roblox.com/groups/api/change-member-rank?groupId={$group}&newRoleSetId=" . getRoleSet($ranks, $rank) . "&targetUserId={$userId}";
    // Get rank URL
    $curl = curl_init($url);
    curl_setopt_array($curl, array(CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array("X-CSRF-TOKEN: {$xcsrf}", 'Content-Length: 0'), CURLOPT_POST => true, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_RETURNTRANSFER => true));
    $response = curl_exec($curl);
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($responseCode != 200) {
        // BELOW 302 DOES NOT WORK AND IS DEPRACATED FOR NOW
        /*if ($responseCode == 302) { // 302 Moved temporarily - User is not logged in: Redirect to error page
        			login($cookie,$username,$password);
        			return updateRank($username,$password,$group,$userId,$rank,$cookie,$ranks,$roles,$rankLimit,$save); // Would appreciate if someone showed me a better way to do this (not repassing every argument manually).
        		} else */
        if ($responseCode == 403) {
            // 403 XCSRF Token Validation Failed - CONVENIENCE!
            $header = http_parse_headers(substr($response, 0, $headerSize));
            $xcsrf = $header['X-CSRF-TOKEN'];
            file_put_contents($save, $xcsrf);
            return updateRank($group, $userId, $rank, $cookie, $ranks, $roles, $rankLimit, $save);
        }
    }
    $response = substr($response, $headerSize);
    curl_close($curl);
    if (json_decode($response, true)['success'] == false) {
        return 'Invalid promoting permissions.';
    } else {
        $current = getRoleSet($ranks, $currentRank);
        $new = getRoleSet($ranks, $rank);
        return "Successfully changed rank of user {$userId} from " . $roles[$current] . ' to ' . $roles[$new] . '.';
        // Details!
    }
}
开发者ID:TebbadRBLX,项目名称:Bots,代码行数:50,代码来源:changeRank.php


示例14: getPingbackServerURL

 public static function getPingbackServerURL($url)
 {
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_NOBODY, true);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $headers = http_parse_headers(curl_exec($curl));
     curl_close($curl);
     if (isset($headers['X-Pingback']) && !empty($headers['X-Pingback'])) {
         return $headers['X-Pingback'];
     }
     $response = file_get_contents($url);
     return preg_match(self::REGEXP_PINGBACK_LINK, $response, $match) ? $match[1] : false;
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:14,代码来源:Utility.php


示例15: handleJoinRequest

function handleJoinRequest($cookie, $group, $username, $choice, $save = 'hxcsrf.txt', $requestId = -1)
{
    $xcsrf = file_exists($save) ? file_get_contents($save) : '';
    $url = "http://www.roblox.com/My/GroupAdmin.aspx?gid={$group}";
    switch ($choice) {
        case 'Accept':
            $choiceNumber = 1;
            break;
        case 'Decline':
            $choiceNumber = 2;
            break;
        default:
            die('Invalid choice.');
    }
    if ($requestId === -1) {
        // This is so that if the function is being re called with the request ID already received you don't go through the whole process again (because it takes up a lot of time)
        $curl = curl_init($url);
        curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie));
        $response = curl_exec($curl);
        $nextPost = getPostArray(substr($response, curl_getinfo($curl, CURLINFO_HEADER_SIZE)), array('ctl00$ctl00$cphRoblox$cphMyRobloxContent$JoinRequestsSearchBox' => $username, 'ctl00$ctl00$cphRoblox$cphMyRobloxContent$JoinRequestsSearchButton' => 'Search'));
        curl_close($curl);
        $curl = curl_init($url);
        curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $nextPost, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie));
        $response = curl_exec($curl);
        $doc = new DOMDocument();
        $doc->loadHTML($response);
        $find = new DomXPath($doc);
        $nodes = $find->query("//span[contains(@class,'btn-control btn-control-medium accept-join-request')][1]");
        foreach ($nodes as $node) {
            $requestId = $node->getAttribute('data-rbx-join-request');
        }
    }
    $curl = curl_init('http://www.roblox.com/group/handle-join-request');
    $post = array('groupJoinRequestId' => $requestId, 'accept' => $choiceNumber == 1 ? true : false);
    curl_setopt_array($curl, array(CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($post), CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array("X-CSRF-TOKEN: {$xcsrf}", 'Content-Length: ' . strlen(json_encode($post)), 'Content-Type: application/json; charset=UTF-8'), CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_RETURNTRANSFER => true));
    $response = curl_exec($curl);
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($responseCode != 200) {
        if ($responseCode == 403) {
            // 403 XCSRF Token Validation Failed
            $header = http_parse_headers(substr($response, 0, $headerSize));
            $xcsrf = $header['X-CSRF-TOKEN'];
            file_put_contents($save, $xcsrf);
            return handleJoinRequest($cookie, $group, $username, $choice, $save, $requestId);
        }
    }
    $text = $choiceNumber == 1 ? 'ed' : 'd';
    return "{$choice}{$text} {$username}'s join request.";
}
开发者ID:VanityRBX,项目名称:roblox-bots,代码行数:50,代码来源:handleJoinRequest.php


示例16: minify

function minify($code)
{
    $ch = curl_init('http://refresh-sf.com/yui/');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('compresstext' => $code, 'semi' => 'on', 'redirect' => '1'));
    curl_setopt($ch, CURLOPT_HEADER, true);
    // curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    $result = http_parse_headers($result);
    $location = 'http://refresh-sf.com' . str_replace('.min.js.gz', '.min.js', $result['Location']);
    curl_close($ch);
    $result = file_get_contents($location);
    return strpos($result, '[ERROR]') ? $code : $result;
}
开发者ID:rncrtr,项目名称:jsperf.com,代码行数:15,代码来源:build.php


示例17: fetch_tarball_via_oauth

 protected static function fetch_tarball_via_oauth($key, $secret, $uri)
 {
     try {
         $oauth = new OAuth($key, $secret);
         $oauth->fetch($uri);
         WP_CLI::debug($oauth->getLastResponseHeaders());
         $headers = http_parse_headers($oauth->getLastResponseHeaders());
         $mime_type = self::parse_content_type_header($headers['Content-Type']);
         $content_disposition = self::parse_content_disposition_header($headers['Content-Disposition']);
         $filename = empty($content_disposition['filename']) ? $filename = tmpfile() : sys_get_temp_dir() . DIRECTORY_SEPARATOR . $content_disposition['filename'];
         file_put_contents($filename, $oauth->getLastResponse());
         return $filename;
     } catch (OAuthException $e) {
         WP_CLI::error_multi_line($e->getMessage(), true);
     }
     WP_CLI::error('Unknown error', true);
 }
开发者ID:nickbreen,项目名称:docker-wp-setup,代码行数:17,代码来源:SCM_Command.php


示例18: send

 public function send($body = null)
 {
     if (isset($body)) {
         $this->curlSetOpt(CURLOPT_POSTFIELDS, $body);
     }
     $response = new \stdClass();
     try {
         $response->body = $this->curlExec();
         $header_size = $this->curlGetinfo(CURLINFO_HEADER_SIZE);
         $response->headers = http_parse_headers(substr($response->body, 0, $header_size));
         $body = substr($response->body, $header_size);
         if ($this->parse_response and array_key_exists('Content-Type', $response->headers)) {
             switch ($response->headers['Content-Type']) {
                 case 'application/json':
                     $response->body = json_decode($body);
                     break;
                 case 'application/xml':
                     $response->body = simplexml_load_string($body);
                     break;
                 case 'application/x-www-form-urlencoded':
                     parse_str($body, $response->body);
                     break;
                 case 'application/vnd.php.serialized':
                     $response->body = unserialize($body);
                     break;
                 case 'text/plain':
                     $response->body = $body;
                     break;
                 default:
                     $response->body = $body;
                     break;
             }
             unset($body);
         } else {
             $response->body = $body;
         }
         $response->errno = $this->curlErrno();
         $response->error = $this->curlError();
         return $response;
     } catch (\Exception $e) {
         exit($e);
     }
 }
开发者ID:KVSun,项目名称:core_api,代码行数:43,代码来源:curl_request.php


示例19: curlGet

function curlGet($url)
{
    global $token;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_URL, $_SESSION['canvasURL'] . '/api/v1/' . $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $GLOBALS['tokenHeader']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // ask for results to be returned
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //Requires to load headers
    curl_setopt($ch, CURLOPT_HEADER, 1);
    //Requires to load headers
    $result = curl_exec($ch);
    // var_dump($result);
    #Parse header information from body response
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $header = substr($result, 0, $header_size);
    $body = substr($result, $header_size);
    $data = json_decode($body);
    curl_close($ch);
    #Parse Link Information
    $header_info = http_parse_headers($header);
    if (isset($header_info['Link'])) {
        $links = explode(',', $header_info['Link']);
        foreach ($links as $value) {
            if (preg_match('/^\\s*<(.*?)>;\\s*rel="(.*?)"/', $value, $match)) {
                $links[$match[2]] = $match[1];
            }
        }
    }
    #Check for Pagination
    if (isset($links['next'])) {
        // Remove the API url so it is not added again in the get call
        $next_link = str_replace($_SESSION['canvasURL'] . '/api/v1/', '', $links['next']);
        $next_data = curlGet($next_link);
        $data = array_merge($data, $next_data);
        return $data;
    } else {
        return $data;
    }
}
开发者ID:NoisyText,项目名称:kennethware-2.0,代码行数:41,代码来源:wizardAPI.php


示例20: exile

function exile($cookie, $group, $senderRoleSetId, $userId, $deletePosts = false, $save = '../Private/excsrf.txt')
{
    $xcsrf = file_exists($save) ? file_get_contents($save) : '';
    $curl = curl_init('http://www.roblox.com/My/Groups.aspx/ExileUserAndDeletePosts');
    $post = array('userId' => $userId, 'deleteAllPostsOption' => $deletePosts, 'rolesetId' => $senderRoleSetId, 'selectedGroupId' => $group);
    curl_setopt_array($curl, array(CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($post), CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array("X-CSRF-TOKEN: {$xcsrf}", 'Content-Length: ' . strlen(json_encode($post)), 'Content-Type: application/json; charset=utf-8'), CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_RETURNTRANSFER => true));
    $response = curl_exec($curl);
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($responseCode != 200) {
        if ($responseCode == 403) {
            // 403 XCSRF Token Validation Failed
            $header = http_parse_headers(substr($response, 0, $headerSize));
            $xcsrf = $header['X-CSRF-TOKEN'];
            file_put_contents($save, $xcsrf);
            return exile($cookie, $group, $senderRoleSetId, $userId, $deletePosts, $save);
        }
    }
    $delete = $deletePosts ? 'deleted' : 'did not delete';
    return "Exiled user {$userId}, {$delete} posts.";
}
开发者ID:TebbadRBLX,项目名称:Bots,代码行数:21,代码来源:exile.php



注:本文中的http_parse_headers函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP http_parse_message函数代码示例发布时间:2022-05-15
下一篇:
PHP http_is_protocol_https函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap