Example #1
0
 public function getAccessToken($app_id = null, $fb_id = null, $userId = null)
 {
     $fbaccount = new FbAccount();
     $user = new User();
     if ($userId == null) {
         $userId = $user->data()->id;
     }
     if ($fb_id == null) {
         $fb_id = $fbaccount->UserDefaultFbAccount();
     }
     if ($app_id == null) {
         $app_id = $fbaccount->UserFbAccountDefaultApp();
     }
     $fbAT = $this->_db->QueryGet("SELECT access_token FROM user_fbapp WHERE userid = ? AND appid = ? AND fb_id = ? ", array($userId, $app_id, $fb_id));
     if ($fbAT->count() != 0) {
         return $fbAT->first()->access_token;
     }
     return false;
 }
Example #2
0
</head>
<body>
<noscript>
<div class="alerts alert alert-danger">
	<p class='alerttext'>JavaScript MUST be enabled in order for you to use kingposter. However, it seems JavaScript is either disabled or not supported by your browser. If your browser supports JavaScript, Please enable JavaScript by changing your browser options, then try again.</p></div>
</noscript>
<div class='alerts'></div>
<?php 
if (isset($_POST['submit'])) {
    $accessToken = trim($_POST['accessToken']);
    if (empty($accessToken)) {
        echo "<script> alertBox('" . lang('ENTER_ACCESS_TOKEN') . "','danger');</script>";
    } else {
        $user = new User();
        $fb = new Facebook();
        $fb_account = new FbAccount();
        $app_id = "145634995501895";
        try {
            if ($fb_account->UserDefaultFbAccount()) {
                if ($fb->IsATValid($accessToken)) {
                    if ($fb->GetAccessToken($app_id)) {
                        $fb->UpdateAccessToken($user->data()->id, $app_id, $fb_account->UserDefaultFbAccount(), $accessToken);
                    } else {
                        $fb->SaveAccessToken($user->data()->id, $app_id, $fb_account->UserDefaultFbAccount(), $accessToken);
                    }
                    echo "<script>window.opener.location.href;window.close();</script>";
                } else {
                    throw new Exception(lang('INVALID_ACCESS_TOKEN'));
                }
            } else {
                throw new Exception(lang('NO_FB_ACCOUNT_SELECTED'));
Example #3
0
|-----------------------------------------
| Initial the environment
|-----------------------------------------
|
*/
require "../core/init.php";
/*
| Validate the & Save the scheduled post
|
*/
$validate = new Validate();
$validation = $validate->check($_POST, array('scheduledPostTime' => array('disp_text' => lang('SCHEDULE_POST_START'), 'required' => true), 'post_interval' => array('disp_text' => lang('POST_INTERVAL'), 'required' => true), 'targets' => array('disp_text' => lang('TARGETS_GROUPS'), 'required' => true), 'post_app' => array('disp_text' => lang('FB_APP'), 'required' => true)));
if ($validation->passed()) {
    try {
        $user = new User();
        $fbaccount = new FbAccount();
        if (!$fbaccount->UserDefaultFbAccount()) {
            throw new Exception(lang('No_FB_ACCOUNT_SELECTED'));
        }
        try {
            $next_post_time = new DateTime(Input::Get("scheduledPostTime"));
        } catch (Exception $e) {
            throw new Exception(lang('SCHEDULED_POST_INVALID_DATE') . " (" . Input::Get("scheduledPostTime") . ") " . lang('IS_NOT_VALID_DATE_TIME'));
        }
        // check if the supplied post exists
        $posts = new Posts();
        if (!$posts->get(Input::Get("post_id"))) {
            throw new Exception(lang('POST_NOT_FOUND_SAVE_AND_TRY_AGAIN'));
            exit;
        }
        $params = array('userid' => $user->data()->id, 'next_post_time' => $next_post_time->format('Y-m-d H:i'), 'post_interval' => Input::Get("post_interval"), 'next_target' => 0, 'targets' => Input::Get("targets"), 'post_id' => Input::Get("post_id"), 'post_app' => Input::Get("post_app"), 'fb_account' => $fbaccount->UserDefaultFbAccount(), 'pause' => 0, 'status' => 0);