顯示包含「facebook」標籤的文章。顯示所有文章
顯示包含「facebook」標籤的文章。顯示所有文章

PHP ~ facebook publish stream


    $params = array(
                  'message'       =>  "Hurray! This works :)",
                  'name'          =>  "This is my title",
                  'caption'       =>  "My Caption",
                  'description'   =>  "Some Description...",
                  'link'          =>  "http://stackoverflow.com",
                  'picture'       =>  "http://i.imgur.com/VUBz8.png",
              );
    $post = $facebook->api("/$user/feed","POST",$params); 

in yii

    $params = array(
                  'message'       =>  "Hurray! This works :)",
                  'name'          =>  "This is my title",
                  'caption'       =>  "My Caption",
                  'description'   =>  "Some Description...",
                  'link'          =>  "http://stackoverflow.com",
                  'picture'       =>  "http://i.imgur.com/VUBz8.png",
              );
    $post = Yii::app() -> facebook -> api("/" . $fbID . "/feed", "POST", $params); 


http://stackoverflow.com/questions/12196576/facebook-php-sdk-publish-stream-oauthexception-200

Facebook ~ Share button


Text link:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a>

Small icon and text:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top left; }</style><a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share on Facebook</a>

Icon only:

<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; } html .fb_share_button:hover { color:#fff; border-color:#295582; background:#3b5998 url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; text-decoration:none; } </style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a>


source
http://askville.amazon.com/add-Share-Facebook-button-webpage/AnswerViewer.do?requestId=1539369

Facebook ~ Anti-force Like

每次看要先like才可以看內容的文

都還沒看就要先讚~~~~~~~~~很瞎耶

蝦爆了


好險現在有這外掛~~~~~只有chrome跟firefox~~XD

可以看這文

http://briian.com/?p=7619



用firefox的可以直接到外掛網址下載~~

https://addons.mozilla.org/zh-TW/firefox/addon/anti-force-like-for-firefox/


之前遇到這種文章我都不想like~~~乾脆就不看了說

現在裝這外掛只要按一下他就出來了~~~不用按讚XD

我是拿這網頁測試的~

睡五分鐘等於六鐘頭的方法 [熬夜的人必看]

Facebook ~ API Error Description: The specified URL is not owned by the application

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.


原本網站還是afweqrq.xzcvasgfxzcvsdf.com/xxxxx.php

後來用apache的rewrite設定網址為awrawsef.sdfgdfsgdsfgdsesa.com/gg/yy

可是這時facebook的登入就出問題了 = =


去設定Site Domain就可以了

xxxxxx.com
Photobucket

Facebook ~ logout my site only

這問題是當自己的網站使用facebook的登出按鈕登出後

連facebook都一起登出了.....

我找了好多文章~~~~~~facebook好像沒提供這種東西~~

就是只登出你的網站~~~~~~並沒登出facebook

比較多人說用session來判斷.......所以我也用session來做= =


一種情況是user還沒登入facebook先進網站

這時候網站還沒登入facebook~~~~~~~~

facebook登入按鈕要用這種~~~~~


<a class="fb_button fb_button_medium" onclick="loginFB()" ><span class="fb_button_text">Login</span></a>

<script type="text/javascript">
function loginFB(){
FB.login(function(response) {
if (response.session) {
//do what you want
} else {
// user cancelled login
}
});
}
</script>


這種方式會跳出一個視窗給你登入facebook~~~~登入之後再看要幹嘛~~~寫在javascript裡



另一種情況是user已經登入facebook~~在進入你的網站

然後希望登入facebook

用這種~~~~~直接連到你要的連結~~~~然後那個位置要做facebook登入要做的動作~~


<a class="fb_button fb_button_medium" href="action/fb_login.php"><span class="fb_button_text">Login</span></a>



登入後就要有session判斷是否登入了

在顯示登出的連結

這個登出連結不能用facebook的登出按鈕

這code是facebook的登入按鈕~~~~可是有登入的話它會自動變登出按鈕


<fb:login-button autologoutlink="true"></fb:login-button>


用這按鈕登出的話會連facebook都一起登出~~~~~因為它的功能就是這樣XD


所以要自己做logout~~~~~要自己清除判斷登入的session~~~~

總之大致是這樣..............

做這功能要進入網站之前就知道user是否已經登入facebook

人家的官方範例有~~~~~

Facebook API ~ how to publish to wallpost example, 發佈到塗鴉牆範例

這個是用Javascript發資訊到FB個人塗鴉牆的範例~~~

整個複製過去就可以了~~~~~~~記得要改一下API Key

------------------------------------------------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<!-- facebook connect -->
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 1111111111111111111111111111111111',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});

// whenever the user logs in, we refresh the page
FB.Event.subscribe('auth.login', function() {
window.location.reload();
});
};

(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<!-- facebook connect -->
<script type="text/javascript">


function share(){
var publish = {
method: 'stream.publish',
message: 'getting educated about Facebook Connect',
attachment: {
name: 'Connect',
caption: 'The Facebook Connect JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://bittyferrari.blogspot.com/',
media: [
{
type: 'image',
href: 'http://bittyferrari.blogspot.com/',
src: 'http://fbrell.com/f8.jpg'
}
]
},
action_links: [
{ text: 'fbrell', href: 'http://bittyferrari.blogspot.com/' }
],
user_prompt_message: 'Share your thoughts about RELL'
};

FB.ui(publish);
}
</script>
<button onclick="share()">share</button>
</body>
</html>

------------------------------------------------------------------------------------------------------------

reference
http://developers.facebook.com/tools/console/

Facebook connect

今天弄facebook connect.......

作法不是用之前的Janrain

是用facebook提供的方法~~~~~~~所以是直接連fb

不是透過Janrain再到FB再到自己網站


作法就是建立新的Application
http://developers.facebook.com/setup/

打網站名網址~下一步

他就會給你App ID, App Secret

順便還給個很簡單的範例

反正放上去可以working就是............


不過最好用他下面提供的範例~~~~~我是PHP所以是選PHP SDK~~XD

http://github.com/facebook/php-sdk/

下載下來開examples/example.php

只要改app id, app secret就好~~~

then開網頁就可以知道他怎麼取facebook的資料了~~~

Facebook connect ~ get Email

如果沒給permission是取不到email的~

<fb:login-button perms="email"></fb:login-button>


reference
http://developers.facebook.com/docs/guides/web

Facebook ~ Like Button

Photobucket

facebook越來越屌了XD

Like的功能竟然可以隨便你愛放哪就放哪~~~~~

可能你的網站~~~~某些網頁想要有功能可以讓人家like~~~~~~~~~

一個是自己做這功能~~~~~~~另一個就是透過Facebook~~~


他的作法整個簡易到爆~~~~~~~~~

真的相當簡單~~~~~~~~ 不用幾個動作就可以輕鬆把這功能坐在自己的網頁上

產生Like按鈕功能的網頁
http://developers.facebook.com/docs/reference/plugins/like

這網頁可以動態~聰明幫你產生code給你用~~~~~你只要貼上去就好了XD


不過比較建議用fb標籤的版本~~~XFBXL

XFBML is more flexible than iframes, but requires you use the JavaScript SDK.

用這比較好~~~~~但要參考一下用法~~~~在這邊

http://developers.facebook.com/docs/reference/javascript/

另外就是要把你的AppID放上去~~~~就是你的Facebook Application ID

設定好就OK了~~~~

PHP ~ test connect to Facebook ~ get user info

最近測試用PHP連線Facebook~~

我是下載人家的demo~~~~
http://wiki.developers.facebook.com/index.php/Connect/Demos

用他的檔案做測試的~~~~

大致上要做的有~~~~~申請Facebook Application

取得API Key 跟 Secret~~~然後在config.php貼上

線上設定Application的URL~~~~~~就好了~


取facebook帳號資料~~~

define(MAIN_PATH, realpath('.'));
include_once MAIN_PATH.'/lib/config.php';
include_once MAIN_PATH.'/lib/core.php';
include_once MAIN_PATH.'/lib/fbconnect.php';
include_once MAIN_PATH.'/lib/user.php';
include_once MAIN_PATH.'/facebook-client/facebook.php';

$user = User::getLoggedIn();

if (!$user) {
echo render_logged_out_index();
echo render_footer();
exit;
}
else
{
if ($user->is_facebook_user()) {
$xxx = facebook_client()->api_client->users_getInfo($user->fb_uid, 'last_name, first_name, website,  sex, birthday ');
print_r($xxx);
}
}


output
Array ( [0] => Array ( [birthday] => June 18, 9999 [first_name] => qqqq [last_name] => ffffffffff [sex] => male [uid] => 11111111111111111 [website] => http://bittyferrari.blogspot.com/ ) )


http://developers.facebook.com/tools.php?api

http://wiki.developers.facebook.com/index.php/Users.getInfo