本文整理汇总了PHP中HttpClient::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::getInstance方法的具体用法?PHP HttpClient::getInstance怎么用?PHP HttpClient::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getGroup
private function _getGroup() {
$apiOauth = new apiOauth();
$access_token = $apiOauth->update_authorizer_access_token($this->wxuser['appid']);
$url = 'https://api.weixin.qq.com/cgi-bin/groups/get?access_token='.$access_token;
$result = HttpClient::getInstance()->get($url);
$result = json_decode($result, true);
return $result;
}
示例2: getGroupId
public function getGroupId()
{
$apiOauth = new apiOauth();
$access_token = $apiOauth->update_authorizer_access_token($this->thisWxUser['appid']);
$url = 'https://api.weixin.qq.com/cgi-bin/groups/getid?access_token=' . $access_token;
$result = HttpClient::getInstance()->post($url, array('post' => json_encode(array('openid' => $this->wechat_id))));
$result = json_decode($result);
return $result->groupid;
}
示例3: getSgin
public function getSgin()
{
if (empty($this->wxuser["is_syn"])) {
$apiOauth = new apiOauth();
$access_token = $apiOauth->update_authorizer_access_token($this->wxuser["appid"], $this->wxuser);
$ticket = $apiOauth->getAuthorizerTicket($this->wxuser["appid"], $access_token);
}
else {
$domain = M("Users")->where(array("id" => $this->wxuser["uid"]))->getField("source_domain");
$url = $domain . A("Home/Auth")->getCallbackUrl($this->wxuser["is_syn"], "share");
$json = HttpClient::getInstance()->get($url);
$json = json_decode($json, true);
$ticket = $json["ticket"];
$this->wxuser["appid"] = $json["appid"];
}
$url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$sign_data = $this->addSign($ticket, $url);
$share_html = $this->createHtml($sign_data);
return $share_html;
}
示例4: file_get_contents
<?php
/**
* Rest client services.
* @author Gecko PHP Generator
* @version 1.0
*/
require 'RestClient/HttpClient.class.php';
$url = "http://52.34.247.215/frameWorkExamples/taskManager/crud/updateTask.php";
$inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, TRUE);
//convert JSON into array
$data = array("taskID" => $input["id"], "status" => $input["status"], "task" => $input["name"], "imagen" => $input["imagen"]);
$merge = array("response" => "rsValue");
$searchValue = isset($_GET['Searchtext']) ? $_GET['Searchtext'] : "";
$start = isset($_GET['start']) ? $_GET['start'] : "";
$count = isset($_GET['count']) ? $_GET['count'] : "";
$cliente = HttpClient::getInstance();
$response = $cliente->getURL("POST", $url, $data);
if ($response == '{}' || $response == null || $response == '[]') {
$response = '{"empty":""}';
}
$cliente->jsonDecode($response);
$cliente->paginate($start, $count, $response);
$result = array();
$cliente->renameJsonKeys($response, $padre = null, $merge, $result);
/*
*/
$cliente->jsonEncode($result);
echo $result;
示例5: IsValid
public function IsValid($access_token)
{
if ($access_token == "") {
return false;
}
$url = "http://tsn.baidu.com/text2audio";
$params["post"] = array();
$params["post"]["tex"] = "test";
$params["post"]["lan"] = "zh";
$params["post"]["tok"] = $access_token;
$params["post"]["ctp"] = 1;
$params["post"]["cuid"] = md5(substr(time() . $access_token, 0, 32));
$params["post"]["per"] = 1;
$params["post"]["spd"] = 5;
$binary_file = HttpClient::getInstance()->post($url, $params);
$result = json_decode($binary_file, true);
if (($result["err_no"] != "") && ($result["err_msg"] != "")) {
return false;
}
else {
return true;
}
}
示例6: sync
public function sync($offset = 0)
{
if ($this->wxuser['winxintype'] < 3) {
$this->error('没有权限');
}
$material = new Material($this->wxuser);
$params['post'] = json_encode(array('type' => 'image', 'offset' => $offset, 'count' => '10'));
$result = $material->batchget($params);
$dirname = '/uploads/' . substr($this->token, 0, 1) . '/' . $this->token . '/material/';
if ('local' == $this->upload_type) {
$this->_mkdir('.' . $dirname);
}
$params['header'] = array('REFERER' => 'http://www.qq.com');
foreach ($result->item as $key => $value) {
if (!empty($value->url)) {
$file = D('Files')->where(array('sync_url' => $value->url, 'token' => $this->token))->find();
if (empty($file)) {
$img = HttpClient::getInstance()->get($value->url, $params);
$extension = pathinfo($value->name, PATHINFO_EXTENSION);
$filename = $dirname . sha1($value->url) . '.' . $extension;
if ('upyun' == $this->upload_type) {
$upyun_pic = new UpYun(UNYUN_BUCKET, UNYUN_USERNAME, UNYUN_PASSWORD, $api_access[0]);
try {
$api_access = array(UpYun::ED_AUTO, UpYun::ED_TELECOM, UpYun::ED_CNC, UpYun::ED_CTT);
$domain_pic = 'http://' . UNYUN_DOMAIN;
$dir_pic = '/' . $this->token . '/material/' . sha1($value->url) . '.' . $extension;
$upyun_pic->writeFile($dir_pic, $img, true);
$filename = $domain_pic . $dir_pic;
}
catch (Exception $e) {
echo json_encode(array('error' => 1, 'message' => $e->getCode() . ':' . $e->getMessage()));
}
}
else {
$size = file_put_contents('.' . $filename, $img);
$filename = $this->siteUrl . $filename;
}
$Files = new Files();
$Files->index($filename, $size, $extension, $this->user['id'], $this->token, 0, $value->url, $value->media_id);
}
}
}
if (($offset + $result->item_count) < $result->total_count) {
$this->success('正在同步 ' . $offset . ' - ' . ($offset + $result->item_count) . '张图片,请稍等...不要关闭此窗口', U('Upyun/sync', array('offset' => $offset + $result->item_count)));
}
else {
$this->success('同步完成', U('Img/index'));
}
}
示例7: getMedia
public function getMedia($post = '')
{
if (($post['news_txt'] == '') || ($post['tok'] == '')) {
return false;
}
$url = 'http://tsn.baidu.com/text2audio';
$params['post'] = array();
$params['post']['tex'] = $post['news_txt'];
$params['post']['lan'] = 'zh';
$params['post']['tok'] = $post['tok'];
$params['post']['ctp'] = 1;
$params['post']['cuid'] = md5(substr(time() . $params['post']['tok'], 0, 32));
$params['post']['per'] = $post['per'] == 1 ? $post['per'] : 0;
$params['post']['spd'] = $post['spd'] ? $post['spd'] : 5;
$binary_file = HttpClient::getInstance()->post($url, $params);
$result = json_decode($binary_file, true);
if (($result['err_no'] != '') && ($result['err_msg'] != '')) {
return array('status' => 'error', 'msg' => $result['err_msg']);
}
else {
$up_domainname = (C('up_domainname') ? str_replace('http://', '', C('up_domainname')) : '');
$upload_type = ((C('upload_type') != '') && ($up_domainname != '') ? C('upload_type') : 'local');
if ($upload_type == 'upyun') {
$temppath = RUNTIME_PATH . substr($params['post']['cuid'], 0, 6) . '.mp3';
file_put_contents($temppath, $binary_file);
$json = $this->Upyun_upload($temppath);
$decode_json = json_decode($json, true);
unlink($temppath);
if (($decode_json['code'] == 200) && ($decode_json['message'] == 'ok')) {
$filepath = 'http://' . $up_domainname . $decode_json['url'];
return array('status' => 'success', 'msg' => $filepath);
}
else {
return array('status' => 'error', 'msg' => $decode_json['message']);
}
}
else {
$firstLetter = substr($this->token, 0, 1);
$savePath = './uploads/frontpage/' . $firstLetter . '/' . $this->token . '/';
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/uploads') || !is_dir($_SERVER['DOCUMENT_ROOT'] . '/uploads')) {
mkdir($_SERVER['DOCUMENT_ROOT'] . '/uploads', 511);
}
$firstDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/frontpage/';
if (!file_exists($firstDir) || !is_dir($firstDir)) {
mkdir($firstDir, 511);
}
$firstLetterDir = $firstDir . $firstLetter;
if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
mkdir($firstLetterDir, 511);
}
if (!file_exists($firstLetterDir . '/' . $this->token) || !is_dir($firstLetterDir . '/' . $this->token)) {
mkdir($firstLetterDir . '/' . $this->token, 511);
}
if (!file_exists($savePath) || !is_dir($savePath)) {
mkdir($savePath, 511);
}
$filePath = $savePath . substr($params['post']['cuid'], 0, 6) . '.mp3';
file_put_contents($filePath, $binary_file);
$filePath = $this->siteUrl . '/' . trim($filePath, './');
return array('status' => 'success', 'msg' => $filePath);
}
}
}
示例8: __construct
public function __construct($wxuser)
{
$this->http = HttpClient::getInstance();
$apiOauth = new apiOauth();
$this->token = $apiOauth->update_authorizer_access_token($wxuser['appid']);
}