当前位置: 首页>>代码示例>>PHP>>正文


PHP HttpClient::setPersistCookies方法代码示例

本文整理汇总了PHP中HttpClient::setPersistCookies方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::setPersistCookies方法的具体用法?PHP HttpClient::setPersistCookies怎么用?PHP HttpClient::setPersistCookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpClient的用法示例。


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

示例1: customHttpClient

function customHttpClient($SERVER, $PATH, $COOKIES, $PARAMS)
{
    //return;//return '{"resHeader":{"backUrl":"","flag":"0","msg":"访问失败"}}';
    //到远程服务器查询登录状态
    include_once dirname(__FILE__) . '/httpclient.inc.php';
    try {
        $client = new HttpClient($SERVER);
        $client->timeout = 10;
        $client->setCookies($COOKIES);
        $client->setPersistCookies(true);
        $postURL = $PATH;
        customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", getHexDecode($client->buildQueryString($PARAMS)));
        if (!$client->post($postURL, $PARAMS)) {
            customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", "\nPUT SERVER:" . $SERVER . "" . $PATH . "\nFAILD1");
            return '{"resHeader":{"backUrl":"","flag":"0","msg":"访问失败1"}}';
        }
    } catch (Exception $e) {
        customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", "\nPUT SERVER:" . $SERVER . "" . $PATH . "\nFAILD2");
        return '{"resHeader":{"backUrl":"","flag":"0","msg":"访问失败2"}}';
    }
    $response = $client->getContent();
    customCreateLogFile(dirname(__FILE__) . "/httpclient_log/" . date('Ymd') . ".txt", "\nPUT SERVER:" . $SERVER . "" . $PATH . "\nPUT COOKIES:" . (is_array($COOKIES) ? var_export($COOKIES, true) : '') . "\nPUT DATA:" . (is_array($PARAMS) ? var_export($PARAMS, true) : $PARAMS) . "\nGET DATA:" . iconv('GBK', 'UTF-8', $response));
    return iconv('GBK', 'UTF-8', $response);
}
开发者ID:CalixtoXie,项目名称:tobeluludoc,代码行数:24,代码来源:func.inc.php

示例2: weixin_bind

 private function weixin_bind($username, $password)
 {
     //		echo 555;exit;
     $new_token = md5($username . $password);
     $new_token = substr($new_token, 2, 15);
     import("@.ORG.HttpClient");
     $http = new HttpClient('mp.weixin.qq.com');
     $http->setPersistCookies(true);
     $http->setPersistReferers(true);
     $http->setCookies(array('uin_cookie' => '85858963', 'euin_cookie' => 'A6C9D89A295536D698C6446BEBE935C403FA57F2166E6962', 'ac' => '1,008,009'));
     $http->get('/');
     $http->post('/cgi-bin/login', array('f' => 'json', 'imgcode' => '', 'username' => $username, 'pwd' => md5($password)));
     $sres = trim($http->getContent(true));
     $reds = json_decode($sres);
     $token = $reds->ErrMsg;
     $token = explode('&token=', $token);
     $token = $token[1];
     //关闭普通接口
     $http->post('/cgi-bin/skeyform?form=advancedswitchform&lang=zh_CN', array('flag' => '0', 'type' => '1', 'token' => $token));
     $http->getContent(true);
     //修改开发路径
     $http->post('/cgi-bin/callbackprofile?t=ajax-response&lang=zh_CN&token=' . $token, array('url' => C('site_url') . '/index.php/api/' . $new_token, 'callback_token' => $new_token));
     $res = $http->getContent(true);
     sleep(1);
     //开启开发接口
     $http->post('/cgi-bin/skeyform?form=advancedswitchform&lang=zh_CN', array('flag' => '1', 'type' => '2', 'token' => $token));
     $http->getContent(true);
     //获取用户微信基本信息
     $http->get('/cgi-bin/settingpage?t=setting/index&action=index&token=' . $token . '&lang=zh_CN');
     $setting = $http->getContent(true);
     preg_match('|<li class="account_setting_item">.*?名称.*?<div class="meta_content">(.*?)</div>.*?</li>.*?<li class="account_setting_item">.*?原始ID.*?<div class="meta_content">.*?<span>(.*?)</span>.*?</div>.*?</li>.*?<li class="account_setting_item">.*?微信号.*?<div class="meta_content">.*?<span>(.*?)</span>.*?</div>.*?</li>|is', $setting, $baseinfo);
     if (trim($baseinfo[1])) {
         $resut = array('wxname' => trim($baseinfo[1]), 'wxid' => trim($baseinfo[2]), 'weixin' => trim($baseinfo[3]), 'token' => $new_token);
     } else {
         $resut = array();
     }
     return $resut;
 }
开发者ID:fengsmith1988,项目名称:weixin-1,代码行数:38,代码来源:IndexAction.class.php


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