显示标签为“facebook”的博文。显示所有博文
显示标签为“facebook”的博文。显示所有博文

2013年8月11日星期日

cakephp Facebook plugin FB.login callback 問題(已解決)

最近因工作需要,開始接觸cakephp用的FB  Plugin,
網路上找到的plugin:
webtechnick/CakePHP-Facebook-Plugin
網址:https://github.com/webtechnick/CakePHP-Facebook-Plugin

透過該網站的說明,將Plugin裝進去後,
第一關(登入)就卡關:

原程式碼:

echo $this->Facebook->login(array(
'perms' => 'email,read_stream,publish_stream',
'id'=>'loginButton',
'show-faces'=>false,
'status'=>'login',
));

狀況:
登入順利進行,但...怎麼登入後沒有導向我指定的網址?
設定網站說明的afterFacebookLogin callback也沒有用,
多加一個參數redirect後:

echo $this->Facebook->login(array(
'perms' => 'email,read_stream,publish_stream',
'id'=>'loginButton',
'show-faces'=>false,
'status'=>'login',
'redirect' => array('controller' => 'frontend', 'action' => 'login'),
));

原本看得到的登入icon,竟然不見了...
這個問題卡了二天,最後才找到解決方法;
根據
的說法,設定redirect參數是有用的,但設定後會發生login icon不見的問題,
所以要手動再設定img參數,如下方程式碼:

echo $this->Facebook->login(array(
'perms' => 'email,read_stream,publish_stream',
'id'=>'loginButton',
'show-faces'=>false,
'status'=>'login',
'redirect' => array('controller' => 'frontend', 'action' => 'login'),
'img'=>'Menubtno.png',
));

圖片因為已不是用原先FB的login圖片了,所以要自己做一張,
放在webroot/Facebook/img下,以上方的程式碼來說,
我有放一張圖在webroot/Facebook/img/Menubtno.png,
按下登入後,終於會導到我的login頁面了。

卡了二天,終於闖過第一關了。

2013年4月18日星期四

android利用Intent分享貼圖至Facebook


基本上利用Android的Intent,就可以簡單的將文字或圖片分享至Facebook,
不過有一個大前提是﹣﹣該台Android必需安裝Facebook的程式

沒有安裝怎麼辦呢?那就只能透過Facebook的API去呼叫了,
但是那樣就必需去研究Facebook的API,會變得比較麻煩。

廢話不多說,分享的程式碼如下:


Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");

intent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://"getSharePictureFile().getAbsolutePath()));  //圖片的實體路徑

startActivity(Intent.createChooser(intent,getString(R.string.share_title).toString()));

執行後,facebook及其他分享程式就會跳出來讓使用者選擇了。

除了
Intent.EXTRA_STREAM放置圖片外,
Intent另外可利用
intent.putExtra(Intent.EXTRA_SUBJECT,baseActivity.getString(R.string.share_title).toString()); //放標題
intent.putExtra(Intent.EXTRA_TEXT, context); //放文字

不過這兩個對Facebook無效。