示例#1
0
文件: api.php 项目: nikilster/I
function processTheRequest($userId)
{
    $function = getIntendedFunction();
    $timezone = getParameter(APIKeys::$TIMEZONE);
    //Login
    if ($function == APIKeys::$FUNCTION_LOGIN) {
        login($timezone);
    } else {
        if ($function == APIKeys::$FUNCTION_CREATE_ACCOUNT) {
            createAccount($timezone);
        } else {
            if ($function == APIKeys::$FUNCTION_GET_INFORMATION) {
                getInformation($userId, $timezone);
            } else {
                if ($function == APIKeys::$FUNCTION_START_ACTIVITY) {
                    startActivity($userId, $timezone);
                } else {
                    if ($function == APIKeys::$FUNCTION_STOP_EVENT) {
                        stopEvent($userId, $timezone);
                    } else {
                        if ($function == APIKeys::$FUNCTION_SET_PUSH_TOKEN) {
                            setPushToken($userId, $timezone);
                        } else {
                            if ($function == APIKeys::$FUNCTION_CREATE_ACTIVITY) {
                                createActivity($userId, $timezone);
                            } else {
                                error();
                            }
                        }
                    }
                }
            }
        }
    }
}
示例#2
0
<?php

require_once "iwiwconnecthelper.php";
// the application consumerKey and consumerSecret
$consumerKey = 'kulcs';
$consumerSecret = 'titkos_kulcs';
// iwiw url eg. sandbox.iwiw.hu, iwiw.hu
$iwiwBaseURL = 'http://sandbox.iwiw.hu';
// iwiw Api url eg. api.sandbox.iwiw.hu, api.iwiw.hu
$iwiwBaseApiURL = 'http://api.sandbox.iwiw.hu';
$osapi = initIWIWConnect($consumerKey, $consumerSecret, $iwiwBaseURL, $iwiwBaseApiURL);
if (osapi) {
    $result = getSelfAndFriends($osapi);
    printResult("<h2>Friend List</h2>", $result);
    $result = createActivity($osapi, 'testtitle', 'testvalue ' . time());
    printResult("<h2>Create Activity</h1>", $result);
    $result = createMessage($osapi, array(9612288), 'testbody' . time());
    printResult("<h2>Create Message</h1>", $result);
} else {
    echo "Error connecting to IWIW !";
}
function printResult($header, $result)
{
    echo $header;
    foreach ($result as $key => $result_item) {
        if ($result_item instanceof osapiError) {
            $code = $result_item->getErrorCode();
            $message = $result_item->getErrorMessage();
            echo "<h3>There was a <em>{$code}</em> error with the <em>{$key}</em> request:</h3>";
            echo "<pre>";
            echo htmlentities($message);
<?php

// deal request for creating a new activity (ok)
session_start();
$theme = $_POST["theme"];
$introduction = $_POST["introduction"];
$userid = isset($_SESSION["userid"]) ? $_SESSION["userid"] : null;
$response = array();
$response["result"] = false;
if ($userid != null) {
    include_once "../model/connect.php";
    include_once "../model/activitymodel.php";
    include_once "../model/audiencemodel.php";
    include_once "../model/filter.php";
    $conn = getConnection();
    $theme = themeFilter($theme);
    $introduction = introductionFilter($introduction);
    $activityid = createActivity($conn, $userid, $theme, $introduction);
    if ($activityid != null) {
        joinActivity($conn, $activityid, $userid);
        $response["result"] = true;
        $response["activityid"] = $activityid;
    }
    mysql_close($conn);
}
header("Content-Type:application/json;charset=utf-8");
echo json_encode($response);
示例#4
0
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 */
require_once 'includes/config.php';
$params = array('eid', 'uid', 'name', 'description', 'sessions');
$values = array();
$title = "Create Activity";
$aid = -1;
$done = false;
foreach ($params as $param) {
    if (isset($_REQUEST[$param])) {
        $values[$param] = safeString($_REQUEST[$param]);
    }
}
if (!isset($values['uid'])) {
    $values['uid'] = $session->userid;
}
if (isset($_POST['activity_create'])) {
    $aid = createActivity($values['eid'], $values['sessions'], $values['uid'], $values['name'], $values['description']);
    $title = 'Activity Created!';
    $done = true;
}
$smarty->assign('values', $values);
$smarty->assign('done', $done);
$smarty->assign('aid', $aid);
$smarty->assign('user', $session->getUser());
$smarty->assign('title', $title);
$smarty->assign('content', $smarty->fetch('create-activity.tpl'));
$smarty->display('skeleton.tpl');