public function post($type)
 {
     $fb = LazySalesHelper::fb();
     $fbApp = LazySalesHelper::fbApp();
     $accessToken;
     if (Input::has('access_token')) {
         $accessToken = Input::get('access_token');
     } else {
         $accessToken = $_SESSION['accessToken'];
     }
     $where;
     $data;
     if ($type != "schedule") {
         if (!empty(Input::get('image'))) {
             $where = 'photos';
             $data = array('source' => $fb->fileToUpload('../public/temp/' . Session::get('image')), 'message' => Input::get('message') . " " . Input::get('link'));
         }
         if (!empty(Input::get('link')) && empty(Input::get('image'))) {
             $where = 'feed';
             $data = array('link' => Input::get('link'), 'message' => Input::get('message'));
         }
         if (!empty(Input::get('message')) && empty(Input::get('link')) && empty(Input::get('image'))) {
             $where = 'feed';
             $data = array('message' => Input::get('message'));
         }
     } else {
         $local_timezone = Config::get('timezone.' . Input::get('timezone'));
         $time = Input::get('schedule');
         $target_timezone = "GMT";
         $datetime = LazySalesHelper::convert_time($time, $local_timezone, $target_timezone);
         $timestamp = strtotime($datetime . "+0");
         if (!empty(Input::get('image'))) {
             $where = 'photos';
             $data = array('source' => $fb->fileToUpload('../public/temp/' . Session::get('image')), 'message' => Input::get('message') . " " . Input::get('link'), 'scheduled_publish_time' => $timestamp, 'published' => 'false');
         }
         if (!empty(Input::get('link')) && empty(Input::get('image'))) {
             $where = 'feed';
             $data = array('link' => Input::get('link'), 'message' => Input::get('message'), 'scheduled_publish_time' => $timestamp, 'published' => 'false');
         }
         if (!empty(Input::get('message')) && empty(Input::get('link')) && empty(Input::get('image'))) {
             $where = 'feed';
             $data = array('message' => Input::get('message'), 'scheduled_publish_time' => $timestamp, 'published' => 'false');
         }
     }
     try {
         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'POST', '/' . Input::get('node') . '/' . $where, $data);
         $response = $fb->getClient()->sendRequest($request);
     } catch (Exception $e) {
         echo $e;
     }
 }
 public static function save()
 {
     date_default_timezone_set('GMT');
     $datetime = date("Y-m-d H:i:s");
     $type = "";
     $image = "";
     $schedule = "0000-00-00 00:00:00";
     if (Input::has('schedule')) {
         $local_timezone = Config::get('timezone.' . Input::get('timezone'));
         $time = Input::get('schedule');
         $target_timezone = "GMT";
         $schedule = LazySalesHelper::convert_time($time, $local_timezone, $target_timezone);
     }
     if (Input::has('album')) {
         $type = "album";
         $image = json_encode(Input::get('image'));
     } else {
         if (!empty(Input::get('image'))) {
             $type = "image";
             $image = Session::get('image');
         }
         if (empty(Input::get('image')) && !empty(Input::get('link'))) {
             $type = "link";
         }
         if (empty(Input::get('image')) && empty(Input::get('link')) && !empty(Input::get('message'))) {
             $type = "message";
         }
     }
     $post = new Post();
     $post->pid = 'NULL';
     $post->uid = $_SESSION['uid'];
     $post->datetime = $datetime;
     $post->type = $type;
     $post->node = json_encode(Input::get('node_list'));
     $post->image = $image;
     $post->link = Input::get('link');
     $post->message = Input::get('message');
     $post->schedule = $schedule;
     $post->save();
 }
示例#3
0
<?php

session_start();
App::setLocale(Session::get('locale', 'en'));
Route::get('/test', function () {
    $schedule = LazySalesHelper::convert_time('2015/12/04 12:30', Config::get('timezone.+7'), 'GMT');
    return $schedule;
});
//Facebook
Route::get('/login', 'FacebookController@login');
Route::get('/callback', 'FacebookController@callback');
Route::get('/data/{where}', 'FacebookController@getdata');
//Home
Route::get('/', 'HomeController@index');
Route::get('/logout', 'HomeController@logout');
Route::post('/lang', 'HomeController@setlang');
Route::post('/history', 'HomeController@gethistory');
Route::post('/save', 'HomeController@save');
//Upload
Route::post('/upload_image', 'UploadController@upload');
Route::post('/upload_album', 'UploadController@upload_album');
//Post
Route::post('/post/{type}', 'PostController@post');
//Create album
Route::post('/create_album', 'AlbumController@create_album');
示例#4
0
<div style='font-size:12px;'><ul style='list-style:none;'>
<?php 
foreach ($post as $row) {
    $datetime = LazySalesHelper::convert_time($row->datetime, 'GMT', $target_timezone);
    if ($row->schedule != "0000-00-00 00:00:00") {
        $schedule = LazySalesHelper::convert_time($row->schedule, 'GMT', $target_timezone);
        ?>
			<li><i class='uk-icon-clock-o'></i> {{$datetime}}<br>
				<i class='uk-icon-share-square-o'></i>{{Lang::get('lazysales.you_scheduled_a')." ".Lang::get('lazysales.'.$row->type)." ".Lang::get('lazysales.at')." ".$schedule}}
			</li>
		<?php 
    } else {
        ?>
			<li><i class='uk-icon-clock-o'></i> {{$datetime}}<br>
				<i class='uk-icon-share-square-o'></i>{{Lang::get('lazysales.you_published_a')." ".Lang::get('lazysales.'.$row->type)}}
			</li>
		<?php 
    }
}
?>
</ul></div>