Loading...

解決FB分享帶參數問題

Temperature: 0 °C

ChungChung
author_tools

又到了FB分享連結的時間了,沒辦法FB太紅...@@...

一般來說如果是以FB的分享網址做分享的方式是這樣:

http://www.facebook.com/sharer/sharer.php?u=網址

所以若寫成Javascript的function會寫成

function putfacebook(){
window.open("http://www.facebook.com/sharer/sharer.php?u=網址");
}

基本上這樣的寫法都沒問題,都能確實把想要分享的meta property如實的分享到FB

但如果想要分享的頁面是需要帶參數去做頁面判斷需要讀取哪一組meta property呢?
例如有一個網址是:
http://www.demo.com/index.php?id=1&tt=a

如果直接把上方的網址貼到FB的動態時報基本上是可行的,FB可以抓到想要分享的內容...。

使用的是FB的除錯頁面 https://developers.facebook.com/tools/debug/og/object/

把上方網址貼入欄位除錯後得到的結果也是一樣是ok的...

但是,若是執行:
http://www.facebook.com/sharer/sharer.php?u=http://www.demo.com/index.php?id=1&tt=a

就發生了FB認不得&後面參數的問題...@@

以下使用了一個解決方式...

http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Feee.demo.com%2Findex.php%3Fid%3D1%26tt%3Da

就是把帶參數的符號做轉換...終於.....

小小的問題折騰了好多時間...@@

https://innstory.com/story-解決FB分享帶參數問題-333
寫程式筆記

Prev
 innstory換裝

Next
花王一匙靈歡馨官網 

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

PHP 利用phpmailer 寄信...

PHP 利用phpmaile...

一般來說其實PHP本身已經提供了Mail()函數可以使用,但由於一些令人不愉快的原因...我租用的V...

動態留言功能調整

動態留言功能調整

guestmap55 最近改進了朋友動態的發文方式.... 一開始在功能方面加上了googlemap...

行事曆功能導入

行事曆功能導入

cc55 Innstory有行事曆囉! 我試著把Innstory當作是我的筆記本,將生活發生的故事紀...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format