Esempio n. 1
0
 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');
     }
 }
Esempio n. 2
0
 public function doCropAvatar($crop)
 {
     //调用上传头像接口改变用户的头像
     $result = callApi('User/applyAvatar', array($crop));
     $this->ensureApiSuccess($result);
     //显示成功消息
     $this->success($result['message'], U('Home/User/step3'));
 }
Esempio n. 3
0
 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_');
     }
 }
Esempio n. 4
0
 protected function getCall($uid)
 {
     if ($uid == is_login()) {
         return '我';
     } else {
         $apiProfile = callApi('User/getProfile', array($uid));
         return $apiProfile['sex'] == 'm' ? '他' : '她';
     }
 }
Esempio n. 5
0
 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' => '活动详情']);
 }
Esempio n. 6
0
 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]);
 }
Esempio n. 7
0
 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]);
 }
Esempio n. 8
0
 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' => '订单列表']);
 }
/**
 * Delete a record from Cloudflare DNS
 */
function deleteRecord($rec_id)
{
    $result = callApi('rec_delete', array('id' => $rec_id));
    return $result['result'] == 'success';
}
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;
}
Esempio n. 11
0
function logActivityGlobal($msg)
{
    $postfields["action"] = "logactivity";
    $postfields["description"] = $msg;
    callApi($postfields);
    error_log($msg);
}
 public function unbookmark($favorite_id)
 {
     //调用API取消收藏
     $result = callApi('User/deleteFavorite', array($favorite_id));
     $this->ensureApiSuccess($result);
     //返回结果
     $this->success($result['message']);
 }
    </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 -->





Esempio n. 14
0
 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,'编辑失败');
     		}*/
 }
Esempio n. 15
0
    	'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' => '*****@*****.**', '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) {
function registerUser($email, $pass, $username, $profile_photo)
{
    if (empty($email)) {
        $email = NULL;
    }
    $crypass = NULL;
    if (!empty($pass)) {
        $crypass = hash("sha256", $pass, false);
    }
    if (empty($username)) {
        $username = NULL;
    }
    $sql = 'INSERT INTO user (email, password, username, profile_photo)
  VALUES (?, ?, ?, ?);';
    $sqlp = $GLOBALS["pdo"]->prepare($sql);
    $fields = array($email, $crypass, $username, $profile_photo);
    $sqlp->execute($fields);
    if ($sqlp->rowCount() == 1) {
        mkdir("img/users/" . $username, 0777);
        callApi('POST', 'http://localhost:8080/MoussaRaser/api/users', array('firstname' => $username, 'lastname' => $username));
        return true;
    } else {
        return false;
    }
}
        $fields = array($positive, $negative, $_SESSION['user_id'], $_POST['imageId']);
        $sqlp->execute($fields);
        $sql = 'SELECT * FROM image WHERE image.id = ?';
        $sqlp = $GLOBALS["pdo"]->prepare($sql);
        $fields = array($_POST['imageId']);
        $sqlp->execute($fields);
        $image = $sqlp->fetch();
        $sql = 'SELECT * FROM opinion INNER JOIN image ON image.id = opinion.id AND image.user_id = ? AND opinion.positive = 1';
        $sqlp = $GLOBALS["pdo"]->prepare($sql);
        $fields = array($image['user_id']);
        $sqlp->execute($fields);
        if ($sqlp->rowCount() == 10) {
            $sql = 'SELECT * FROM user WHERE id = ?';
            $sqlp = $GLOBALS["pdo"]->prepare($sql);
            $fields = array($image['user_id']);
            $sqlp->execute($fields);
            $user = $sqlp->fetch();
            $endUsers = json_decode(callApi('GET', 'http://localhost:8080/MoussaRaser/api/users'));
            foreach ($endUsers as $endUser) {
                if ($endUser->firstName == $user['username']) {
                    callApi('POST', 'http://localhost:8080/MoussaRaser/api/events', array('eventType' => 'tenratings', 'toUserId' => $endUser->id));
                    break;
                }
            }
        }
        echo json_encode(array('ok' => 1));
    } else {
        echo json_encode(array('ok' => 0));
    }
    exit;
}
Esempio n. 18
0
// GET SINGLE call to api and verified against Test_Form_1.
$getSingleUrl = 'https://www.formstack.com/api/v2/form/2169122.json';
$getSingleResponse = callApi($getSingleUrl);
echo "\n Single Form Verification";
verifyResponse($getSingleResponse, $getSingleArray);
// POST to make a copy and verified against original form.
$copySingleUrl = 'https://www.formstack.com/api/v2/form/2169122/copy.json';
$copyResponse = callApi($copySingleUrl, "POST");
$copiedId = $copyResponse['id'];
$copiedName = $copyResponse['name'];
$getCopyArray = array('id' => "{$copiedId}", 'name' => "{$copiedName}");
echo "\n Copied Form Verification";
verifyResponse($copyResponse, $getCopyArray);
// DELETE to the copied form id and verification against correct array.
$newCopyUrl = "https://www.formstack.com/api/v2/form/{$copiedId}.json";
$deleteResponse = callApi($newCopyUrl, "DELETE");
$deletedName = $deleteResponse['name'];
$deletedId = $deltedResponse['id'];
$getDeleteArray = array('id' => "{$copiedId}", 'success' => "1");
echo "\n Deleted Form Verification";
verifyDeleteResponse($deleteResponse, $getDeleteArray);
// Function calls api
//
// $url  -  the url to call
// $type -  GET, PUT, POST, DELETE\
// #data -  array of data to send to the api
//
function callApi($url, $type = "GET", $data = array())
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Esempio n. 19
0
                if (trim($issue->description)) {
                    echo PHP_EOL;
                    echo "Description: {$issue->description}", PHP_EOL;
                }
            } else {
                echo "Usage: issue <id>", PHP_EOL;
            }
            break;
        case "new":
        case "n":
        case "create":
            echo 'Creating a new issue:', PHP_EOL;
            $name = prompt('Name: ', null, false);
            $owner = prompt('Assignee ID: ', null, false, true) ?: $user->id;
            $desc = promptMultiline('Enter a description, ending with a line containing only ".": ');
            $response = callApi('issues.json', 'POST', array('name' => $name, 'owner_id' => $owner, 'description' => $desc));
            if (!empty($response->error)) {
                echo "Error {$response->status} creating issue: {$response->error}", PHP_EOL;
            } else {
                echo "Issue created, ID {$response->issue->id}.", PHP_EOL;
            }
            break;
        default:
            echo "Command not found: {$cmd}", PHP_EOL;
    }
}
// Display quit message
exit("Bye!" . PHP_EOL);
////////////////////////////////////////////////////
/// Internal functions for prompts and validaton ///
////////////////////////////////////////////////////
Esempio n. 20
0
 public function doChangePassword($old_password, $new_password)
 {
     //调用接口
     $result = callApi('User/changePassword', array($old_password, $new_password));
     $this->ensureApiSuccess($result);
     //显示成功信息
     $this->success($result['message']);
 }
// Check if file already exists
if (file_exists($target_file)) {
    $reponse = "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
/*if ($_FILES["photo_upload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}*/
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
    $reponse = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
$isFirstPost = false;
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    $reponse = "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["photo_upload"]["tmp_name"], $target_file)) {
        $isFirstPost = insertImage($_SESSION['user_id'], $target_file_db, $_POST['photo_caption']);
    } else {
        $reponse = "Sorry, there was an error uploading your file.";
    }
}
if ($isFirstPost) {
    callApi('POST', 'http://localhost:8080/MoussaRaser/api/events', array('eventType' => 'firstpost', 'toUserId' => $_SESSION['gamification_user_id']));
}
echo json_encode(['isFirstPost' => $isFirstPost, 'reponse' => $reponse, 'path' => $target_file_db, 'text' => $_POST['photo_caption'], 'profile_photo' => $_SESSION['profile_photo'], 'username' => $_SESSION['username']]);
Esempio n. 22
0
 public function createPay()
 {
     $id = Input::get('id', 0);
     $user_id = Cookie::get('user_id', 0);
     $openid = Cookie::get('open_id', '');
     $result = [];
     try {
         $res = callApi('1.0/pay/create', ['order_id' => $id, 'user_id' => $user_id, 'open_id' => $openid]);
         if ($res->status == 'success') {
             $result['status'] = 'success';
             $result['result'] = $res->result;
             echo json_encode($result);
             exit;
         } else {
             $result['status'] = 'err';
             $result['msg'] = $res->message;
             echo json_encode($result);
             exit;
         }
     } catch (Exception $e) {
         $result['status'] = 'err';
         $result['message'] = '创建支付订单出错';
         echo json_encode($result);
         exit;
     }
 }
Esempio n. 23
0
 public function doUploadAvatar()
 {
     //调用上传头像接口
     $result = callApi('User/uploadTempAvatar');
     //result就是数组
     $this->ajaxReturn($result);
 }
</td>
            <td>
              <img src="<?php 
        echo $badge->image;
        ?>
" width="50px" style="padding-left: 20px"/>
            </td>
          </tr>
        <?php 
    }
    ?>
      </tbody>
    </table>
    <?php 
}
$rewards = json_decode(callApi('GET', 'http://localhost:8080/MoussaRaser/api/users/' . $_SESSION['gamification_user_id'] . '/rewards'));
if (empty($rewards)) {
    echo '<h1>No reward</h1>';
} else {
    ?>

    <table class="table table-striped table-responsive">
      <thead>
        <th>Name</th>
        <th>Category</th>
        <th>Description</th>
        <th>Reward</th>
      </thead>
      <tbody>
        <?php 
    foreach ($rewards as $reward) {
      <span class="scroll-top-inner">
        <i class="fa fa-2x fa-arrow-circle-up"></i>
      </span>
    </div>

    <h1>Leaderboard</h1>

    <table class="table table-striped table-responsive">
      <thead>
        <th>#</th>
        <th>Username</th>
        <th>Score</th>
      </thead>
      <tbody>
          <?php 
$leaderboard = json_decode(callApi('GET', 'http://localhost:8080/MoussaRaser/api/leaderboard'));
$i = 1;
foreach ($leaderboard as $user) {
    ?>
        <tr>
          <td><?php 
    echo $i;
    ?>

          <?php 
    if ($i == 1) {
        ?>
            <img src="https://cdn0.iconfinder.com/data/icons/gamification-flat-awards-and-badges/500/crown1-512.png" width="50px" style="padding-left: 20px"/>
          <?php 
    } elseif ($i == count($leaderboard)) {
        ?>