Exemplo n.º 1
0
function getWxUserByOpenid($openid)
{
    $access_token = getAccessToken();
    $param = array('access_token' => $access_token, 'openid' => $openid, 'lang' => 'zh_CN');
    $url = "https://api.weixin.qq.com/cgi-bin/user/info";
    //获取userinfo"
    $resp = SimpleHttpClient::get($url, $param);
    $resp = parseResponse($resp);
    return $resp;
}
Exemplo n.º 2
0
function _oid_httpclient_test()
{
    $url_get = 'http://www.google.com';
    $c1 = new SimpleHttpClient();
    $response = $c1->get($url_get);
    if ($response) {
        list($url, $data) = $response;
        echo $data;
    } else {
        echo "test 1 failed";
    }
}
Exemplo n.º 3
0
 public function get($method, $params = array())
 {
     return $this->parseResponse(SimpleHttpClient::get(self::$apiEntry, $this->buildRequestParams($method, $params)));
 }
Exemplo n.º 4
0
<?php

include "./lib/Util.class.php";
include "./lib/SimpleHttpClient.class.php";
$dataPath = "/usr/local/data/comics";
$linkPattern = "#<div\\sclass=\"img\\-url\">//(.*?)</div>#is";
$imagePattern = "#/([-_0-9a-zA-Z]+)/([-\\._0-9a-zA-Z]+\\.\\w{3})#is";
$titlePattern = "#<title>(.*?)\\|[^\\|]*?</title>#is";
$baseUrl = "https://";
if (!isset($argv[1])) {
    die("Uso: " . $argv[0] . " url|file\n");
}
$galeryUrl = $argv[1];
$galeryUrl = str_replace("/galleries/", "/reader/", $galeryUrl);
$client = new SimpleHttpClient();
$content = $client->get($galeryUrl);
if (!preg_match_all($linkPattern, $content, $matches)) {
    die("Não foram encontradas imagens\n{$content}\n");
}
print "Foram encontradas " . count($matches[1]) . " imagens\n";
if (preg_match($titlePattern, $content, $m)) {
    $destDir = $dataPath . "/" . Util::asSlug($m[1]);
    if (!is_dir($destDir)) {
        mkdir($destDir);
    }
}
$client->setBinaryTransfer(true);
$i = 0;
foreach ($matches[1] as $link) {
    $i++;
    if (!preg_match($imagePattern, $link, $m)) {