本文整理汇总了PHP中callApi函数的典型用法代码示例。如果您正苦于以下问题:PHP callApi函数的具体用法?PHP callApi怎么用?PHP callApi使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了callApi函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scope_base
public function scope_base()
{
$code = Input::get('code', '');
$state = Input::get('state', '');
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxe7d58fa8d7ae3416&secret=2204083b829c499d245a46849b2befb2&code=" . $code . "&grant_type=authorization_code";
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$uri = urldecode($state);
$res = json_decode($result, TRUE);
$open_id = $res['openid'];
$data = callApi('1.0/user/wx/info', ['wx_id' => $open_id]);
if ($data->status == 'success') {
if (!empty($data->result)) {
$id_cookie = Cookie::forever('user_id', $data->result->id);
$open_id_cookie = Cookie::forever('open_id', $open_id);
return Redirect::to($uri)->withCookie($id_cookie)->withCookie($open_id_cookie);
} else {
return Redirect::route('forbidden');
}
} else {
return Redirect::route('forbidden');
}
} catch (Exception $e) {
return Redirect::route('forbidden');
}
}
示例2: doCropAvatar
public function doCropAvatar($crop)
{
//调用上传头像接口改变用户的头像
$result = callApi('User/applyAvatar', array($crop));
$this->ensureApiSuccess($result);
//显示成功消息
$this->success($result['message'], U('Home/User/step3'));
}
示例3: getCall
protected function getCall($uid)
{
if ($uid == is_login()) {
return L('_I_');
} else {
$apiProfile = callApi('User/getProfile', array($uid));
return $apiProfile['sex'] == 'm' ? L('_HE_') : L('_SHE_');
}
}
示例4: getCall
protected function getCall($uid)
{
if ($uid == is_login()) {
return '我';
} else {
$apiProfile = callApi('User/getProfile', array($uid));
return $apiProfile['sex'] == 'm' ? '他' : '她';
}
}
示例5: info
public function info()
{
$msg = '';
$activity_id = Input::get('id', 0);
$data = [];
$res = callApi('1.0/activity/info', ['activity_id' => $activity_id]);
if ($res->status == 'success') {
$data = $res->result;
} else {
$msg = $res->message;
}
return View::make('activity.info', ['data' => $data, 'msg' => $msg, 'pageTitle' => '活动详情']);
}
示例6: image
public function image()
{
$msg = '';
$image_id = Input::get('id', 0);
$album_id = Input::get('album_id', 0);
$image_info = callApi('1.0/album/image/info', ['image_id' => $image_id]);
if ($image_info->status && !empty($image_info->result->image) && !empty($image_info->result->template) && !empty($image_info->result->class)) {
$data = $image_info->result;
} else {
$msg = '获取数据错误';
}
return View::make('make.image', ['msg' => $msg, 'pageTitle' => '制作照片', 'data' => $data, 'album_id' => $album_id]);
}
示例7: create
public function create()
{
$user_id = Cookie::get('user_id', 0);
$album_id = Input::get('album_id', 0);
$user_info = [];
$user = callApi('1.0/user/info', ['user_id' => $user_id]);
if ($user->status == 'success') {
$user_info = $user->result;
} else {
$msg = $user->message;
}
return View::make('order.create', ['album_id' => $album_id, 'user' => $user_info]);
}
示例8: orderList
public function orderList()
{
$msg = '';
$user_id = Cookie::get('user_id', 0);
$res = [];
$data = callApi('1.0/my/order/list', ['user_id' => $user_id]);
if ($data->status == 'success') {
if (empty($data->result)) {
$msg = '没有数据';
} else {
$res = $data->result;
}
} else {
$msg = $data->message;
}
return View::make('my.orderList', ['msg' => $msg, 'data' => $res, 'pageTitle' => '订单列表']);
}
示例9: deleteRecord
/**
* Delete a record from Cloudflare DNS
*/
function deleteRecord($rec_id)
{
$result = callApi('rec_delete', array('id' => $rec_id));
return $result['result'] == 'success';
}
示例10: callApi
function callApi($url, array $save, array $customFields)
{
var_dump($url);
$data = file_get_contents($url);
$issuesData = array();
if (empty($data)) {
outputError('No data returned from: ' . $redmineUrl);
outputError('Full request: ' . $url);
return $issuesData;
}
// save issues data
$d = new SimpleXMLElement($data);
foreach ($d->issue as $issue) {
$issueCopy = array();
foreach ($save as $key => $opt) {
if (is_array($opt)) {
if (isset($issue->{$key})) {
foreach ($issue->{$key}->attributes() as $attr => $val) {
if (in_array($attr, $opt)) {
$issueCopy[$key . '_' . $attr] = (string) $val;
}
}
}
} else {
$issueCopy[$key] = (string) $issue->{$key};
}
}
foreach ($issue->custom_fields->custom_field as $customField) {
foreach ($customField->attributes() as $attr => $val) {
if ('id' === $attr) {
$val = (string) $val;
if (isset($customFields[$val])) {
$issueCopy[$customFields[$val]] = (string) $customField->value;
}
}
}
}
$issuesData[] = $issueCopy;
}
$t = (int) $d['total_count'];
$o = (int) $d['offset'];
$l = (int) $d['limit'];
if ($t > $o + $l) {
$url .= '&offset=' . ($o + $l);
$issuesData = array_merge($issuesData, callApi($url, $save, $customFields));
}
return $issuesData;
}
示例11: logActivityGlobal
function logActivityGlobal($msg)
{
$postfields["action"] = "logactivity";
$postfields["description"] = $msg;
callApi($postfields);
error_log($msg);
}
示例12: unbookmark
public function unbookmark($favorite_id)
{
//调用API取消收藏
$result = callApi('User/deleteFavorite', array($favorite_id));
$this->ensureApiSuccess($result);
//返回结果
$this->success($result['message']);
}
示例13: array
</div>
</section><?php
}
}
} else {
echo "";
}
?>
<div class="text-center">
<?php
$map = array($cid, 'true', '0', '1', '', '', '', '');
$data = callApi("Art/getArtCount", $map);
$count = $data['data'];
$__PAGE__ = new \Think\Page($count, 10);
echo $__PAGE__->show();
?>
</div>
</div>
</div><!-- /.main -->
示例14: update
public function update()
{
//$Api = new UserApi();
$model = D('Member');
$uid = I('post.uid');
$username = I('post.username');
$email = I('post.email');
$nickname = I('post.nickname');
$mroleId = I('post.mroleId', 0);
$roleId = I('post.roleId', 0);
$score = I('post.score', 0);
$data = array('nickname' => $nickname, 'username' => $username, 'email' => $email, 'uid' => $uid, 'score' => $score, 'id' => $uid);
if ($roleId == 0) {
M('role_user')->delete($uid);
}
if ($mroleId == 0) {
M('mrole_user')->delete($uid);
}
$res = callApi('Public/updateUser', array($uid, $data));
if (!$res['success']) {
$this->mtReturn(300, $res['message']);
} else {
$this->after_update($uid, $roleId, $mroleId);
clean_query_user_cache($uid, array('nickname', 'email', 'username'));
$this->mtReturn(200, '编辑成功');
}
/*
if (false === $data1= $model->create()) {
$this->mtReturn(300, $model->getError());
}
if(false !== D('Member')->save($data1)){
$data=array(
'id'=>$uid,
'username'=>$username,
'email'=>$email
);
$res = $Api->updateInfo($uid, 'admin', $data);
if ($res['status']) {
$this->_after_update($uid);
clean_query_user_cache($uid,array('nickname','email','username'));
$this->mtReturn(200,'编辑成功');
} else {
$this->mtReturn(300,$res['info']);
}
}else{
$this->mtReturn(300,'编辑失败');
}*/
}
示例15: array
'26660787' => '192.168.1.1',
),
'priority' => 'normal'
));*/
/*
// Update multiple tickets
$client->ticket(array(123, 456))->update(array(
'status' => 'urgent'
));
// Delete a ticket
$client->ticket(123)->delete();
*/
$data = array('user' => array('name' => 'rayjohn123', 'email' => 'paperchrisrey2@gmail.com', 'user_fields' => array('nats_id' => 1234556, 'siteid' => 15)));
$adduser = callApi('POST', 'https://paperstreet-ray.zendesk.com/api/v2/users.json', $data);
echo '<pre>';
var_dump($adduser);
echo '</pre>';
/*
//get user
$getuser = callApi('GET', 'https://paperstreet-ray.zendesk.com/api/v2/users.json');
echo '<pre>';
print_r($getuser);
echo '</pre>';
*/
function callApi($method, $url, $datas = false)
{
$curl = curl_init();
switch ($method) {