<?php $appid = ''; // your AppID $secret = ''; // your secret // init app with app id (APPID) and secret (SECRET) FacebookSession::setDefaultApplication($appid ,$secret); $session = new FacebookSession($_SESSION['demo_accessToken']); $session_long_lived = $session->getLongLivedSession($appid, $secret); $request = new FacebookRequest( $session_long_lived, 'GET', '/me/accounts' ); $response = $request->execute(); $graphArray = $response->getGraphObject()->asArray();get it~ You can check it by Facebook debug tools
2014年7月16日 星期三
Facebook PHP SDK 4.0 get long lived session/token for manage_pages
2014年7月9日 星期三
codeigniter 設定 Medoo database framework為library
Medoo為一個蠻好用的database framework
一直很想把它加進codeigniter使用
首先file medoo.php in application/libraries:
<?php class medoo { protected $database_type = 'mysql'; // For MySQL, MariaDB, MSSQL, Sybase, PostgreSQL, Oracle protected $server = 'localhost'; ......略 }之後就能夠直接取用此工具囉!~ ex:
<?php Controller admin.php in application/controllers class Admin extends CI_Controller { function index() { $this->load->library('medoo','datebase_name'); //第二欄位可設params $data = $this->medoo->select('table_name', '*'); } }
codeigniter 備份目前網站資料庫
因為一些因素必須要撰寫公司網站資料庫備份的排程
所以筆記一下以做為以後方便查找:
在controller:
所以筆記一下以做為以後方便查找:
在controller:
<?php class Mybackup extends MY_Controller { public function index(){ $this->load->dbutil(); // Backup your entire database and assign it to a variable $backup =& $this->dbutil->backup(); // Load the file helper and write the file to your server $this->load->helper('file'); if (!write_file('./mybackup.zip', $backup)){ echo 'Unable to write the file'; } else{ echo 'File written!'; } } }網站目錄(預設根目錄)可取得..mybackup.zip這個檔案囉
訂閱:
文章 (Atom)