2016年5月23日 星期一

2016年5月9日 星期一

[FB][分享]javascript sdk

參考網址:

  1. https://dotblogs.com.tw/suehilary/2012/02/08/68441
  2. [登入] https://developers.facebook.com/docs/javascript/examples#login
  3. [javascript sdk] https://developers.facebook.com/docs/javascript/examples

javascript範例:


//判斷是否登入中
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback3(response);
});
}

// 判斷登入狀態
function statusChangeCallback3(response) {
console.log('statusChangeCallback');
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
api_me(response);
// console.log(response);
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
console.log('not_authorized');
// document.getElementById('status').innerHTML = 'Please log ' + 'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
console.log('else');
// document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.';
}
}

// 登入中取得資訊後,像後端傳送資料
function api_me(login_status) {
var access_token = login_status.authResponse.accessToken;
FB.ui({
method: 'feed',
name: '分享標題',
link: 'https://google.com',//分享連結
picture: 'https://google.com',//分享圖片
caption: '分享資訊',
description: '分享資訊'
}, function(response) {
if (response && response.post_id) {
var post_id = response.post_id;
FB.api('/me?fields=email,name,first_name,last_name', function(response) {
email = response.email || "";
$.ajax({
url: "", //後台api
dataType: 'json',
method: 'POST',
data: {
'post_id' : post_id,
'name' : response.name,
'account' : response.id,
'email': email,
},
success: function(result) {
console.log(result);
if (result.status=='ok') {
alert('已完成');
} else {
alert('請與客服聯絡');
}
},
error: function(err) {
console.log(err);
alert('發生錯誤');
}
});
});
} else {
alert('Post was not published.');
}
});
}

nginx和centos php設定

nginx file:

fastcgi_pass unix:/var/run/php5-fpm.sock;

change to

fastcgi_pass 127.0.0.1:9000;

2016年4月27日 星期三

Multiple SSH Keys settings for different key with same host

由於連線位置都是155.100.xxx.xxx,但是key不同會產生,第二個相同git無法抓取到資料問題。
所以需要在~/.ssh/config動手腳。

原先:

$ vi ~/.ssh/config
Host 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex1.pem

Host 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex2.pem


$ git clone ex1@155.100.xxx.xxx:proj_1
success

$ git clone ex1@155.100.xxx.xxx:proj_2
Cloning into 'fs/server/warinode'...
FATAL: R any fs/server/warinode fttwsmt DENIED by fallthru
(or you mis-spelled the reponame)
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

會發現第二個無法正常clone




修改後:

下方紅色字體為增加內容。

$ sudo chmod 400 ~/.ssh/ex1.pem
$ sudo chmod 400 ~/.ssh/ex2.pem

$ vi ~/.ssh/config
Host ex1 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex1.pem

Host ex2 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex2.pem


$ git clone ex1@ex1:proj_1
success

$ git clone ex1@ex2:proj_2
success

2016年4月13日 星期三

linux port - make sock


error:
Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:port
 (13)Permission denied: make_sock: could not bind to address 0.0.0.0:port
no listening sockets available, shutting down
Unable to open logs


解決方法:
$ sudo setenforce 0