public function create_album() { $fb = LazySalesHelper::fb(); $fbApp = LazySalesHelper::fbApp(); $accessToken; if (Input::has('access_token')) { $accessToken = Input::get('access_token'); } else { $accessToken = $_SESSION['accessToken']; } try { $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'POST', '/' . Input::get('node') . '/albums', array('name' => Input::get('album_tittle'), 'message' => Input::get('album_decription'))); $response = $fb->getClient()->sendRequest($request); $album_id = $response->getGraphNode()->getProperty('id'); $list_decrip = Input::get('list_decrip'); foreach (Input::get('list_images') as $key => $value) { $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'POST', '/' . $album_id . '/photos', array('source' => $fb->fileToUpload('../public/temp/' . $value), 'message' => $list_decrip[$key])); $response = $fb->getClient()->sendRequest($request); } } catch (Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch (Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } }
public static function getdata($where) { if (Request::ajax()) { if (isset($_SESSION["accessToken"])) { $fb = LazySalesHelper::fb(); $fbApp = LazySalesHelper::fbApp(); $fields = "/me/groups?fields=id,name&limit=500"; if ($where == "page") { $fields = "/me/accounts?fields=id,name,access_token&limit=500"; } try { $request = new Facebook\FacebookRequest($fbApp, $_SESSION["accessToken"], 'GET', $fields); $response = $fb->getClient()->sendRequest($request); } catch (Exception $e) { echo $e; } $data = $response->getGraphEdge()->asArray(); if (!empty($data)) { return View::make('LazySales.data', array('data' => $data, 'where' => $where)); } else { if ($where == "group") { return Lang::get('lazysales.cant_load_the_groups_list'); } else { return Lang::get('lazysales.cant_load_the_pages_list'); } } } } }
public function gethistory() { App::setLocale(Session::get('locale', 'en')); $fb = LazySalesHelper::fb(); $fbApp = LazySalesHelper::fbApp(); $post = Post::where('uid', '=', $_SESSION['uid'])->get(); if ($post != "[]") { $target_timezone = Config::get('timezone.' . Input::get('timezone')); return View::make('LazySales.history', array('target_timezone' => $target_timezone, 'post' => $post)); } else { return Lang::get('lazysales.history_empty'); } }
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; } }
<?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');
<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>