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

如何用javascript判斷字串中必須包含中英文

如何用javascript判...

字串拆開逐字檢查方式~ 首先將每一個字轉換成 ASCII 碼。 在使用for迴圈去檢查每個字是不是在...

HTML5 Geolocation

HTML5 Geolocat...

說真的,HTML5 Geolocation的功能真的好用... 輕鬆就可以讓網站也能取得目前所在的地...

校外教學(木柵動物園)

校外教學(木柵動物園)

期中考週的校外教學,來到了上回去不成的木柵動物園。 炎熱的天,帶著位小蘿蔔頭,一邊觀察一邊完成老師交...

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