2016-07-07 112 views
1

所以我想爲我的網站上的個別文章添加一個Facebook和Twitter分享按鈕。文章使用URL中的一個php GET變量顯示。 Twitter和Facebook分享按鈕位於主頁上,與他們分享的頁面不同(他們正在共享他們鏈接到的文章的頁面)。我有兩個按鈕的代碼現在是推特和臉書分享網站分享按鈕

的Twitter:

$url = rawurlencode("http://www.weGamblePro.com/article.php?article={$title}"); 
<a href='http://twitter.com/share?url=$url' class='twitter-share-button'>Tweet</a> 

Facebook的:

<div style='float: right;' class='fb-share-button' 
    data-href='http://www.weGamblePro.com/article.php?article=$title' 
    data-layout='button_count'> 
</div> 
  1. 我的第一個問題是在Twitter分享按鈕只股票的標題主頁,並且根本沒有URL。我希望它分享文章的網址(就像它是如何在$ url變量中)。

  2. 我的第二個問題是facebook分享,它分享正確的頁面,但我希望能夠編輯描述,標題和圖像。

對這兩個問題的建議將不勝感激。

感謝。

渲染例如:www.weGamblePro.com

+0

將我們鏈接到一個實際示例,而不是審查域,包括兩個按鈕(不是預渲染的PHP)的最終呈現HTML。 – ceejayoz

+0

www.weGamblePro.com ...編輯帖子。 –

+1

像http://www.wegamblepro.com/article.php?article=Sports%20Betting%20Totals:%201989-2015這樣的網址似乎沒有包含每篇文章標題的「」標籤。他們也缺乏Facebook的'og'元標記。 Facebook的調試器提供了具體的建議和提示:https://developers.facebook.com/tools/debug/sharing/?q=http%3A%2F%2Fwww.wegamblepro.com%2Farticle.php%3Farticle%3DSports%2520Betting%2520總計%3A%25201989-2015 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/1902010/">ceejayoz</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="answer-title"> <span class="text-logo margin-top-sm">A</span> <h2 class="title h4">回答</h2> </div> <div class="item-description text-md markdown-body margin-bottom-40 voidso"> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">1<i class="fa fa-thumbs-up"></i></span> <i class="fa fa-check fa-2x"></i> </div> <div class="post-offset"> <div class="answer fmt"> <p>以<a href="http://www.wegamblepro.com/article.php?article=Sports%20Betting%20Totals:%201989-2015" rel="nofollow">http://www.wegamblepro.com/article.php?article=Sports%20Betting%20Totals:%201989-2015</a>爲例:</p> <ol> <li><p>你<code class="prettyprint-override"><title></code>標籤<code class="prettyprint-override"><title>weGamble | Article</title></code>。這就是Facebook使用的。在標題標籤中輸出<code class="prettyprint-override">$title</code>,Facebook將使用它。</p></li> <li><p>您可以通過Facebook的Open Graph標記控制標題,描述,圖片等,如<a href="https://developers.facebook.com/docs/sharing/webmasters" rel="nofollow">documented here</a>。從他們的例子... <code class="prettyprint-override"><meta property="og:description" content="How much does culture influence creative thinking?" /></code></p></li> <li><p><a href="https://developers.facebook.com/tools/debug/sharing/?q=http%3A%2F%2Fwww.wegamblepro.com%2Farticle.php%3Farticle%3DSports%2520Betting%2520Totals%3A%25201989-2015" rel="nofollow">Facebook debugger</a>會告訴你所有這些事情,並提供建議和看看爲什麼Facebook選擇什麼選擇顯示您的網址。</p></li> </ol> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/38255157">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2016-07-07 20:58:46</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/1902010/">ceejayoz</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> </div> </article> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1038284119" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-xslsxynm-cw.html" target="_blank" title="推特/臉書分享動態網址"> 推特/臉書分享動態網址 </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-kztpzowj-bmc.html" target="_blank" title="推特按鈕,分享推文"> 推特按鈕,分享推文 </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-bsruimcy-uo.html" target="_blank" title="如何與臉書和推特分享照片?"> 如何與臉書和推特分享照片? </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-erhyusyc-hx.html" target="_blank" title="分享臉書的描述"> 分享臉書的描述 </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-aphqbnfg-km.html" target="_blank" title="推特「Tweet分享」按鈕不工作"> 推特「Tweet分享」按鈕不工作 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-mvfzufwj-zm.html" target="_blank" title="分享 - 網站中的社交按鈕"> 分享 - 網站中的社交按鈕 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-ftnoepxj-eq.html" target="_blank" title="在https網站上分享按鈕"> 在https網站上分享按鈕 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-pxozusbl-bhk.html" target="_blank" title="網站的Facebook分享按鈕"> 網站的Facebook分享按鈕 </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-xfgywrca-bkq.html" target="_blank" title="在臉書上分享帶有圖像的網站內容"> 在臉書上分享帶有圖像的網站內容 </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-wnmetytm-rt.html" target="_blank" title="在網站上分享html5視頻到臉書"> 在網站上分享html5視頻到臉書 </a> </li> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-tmxefajc-xb.html" target="_blank" title="所有圖像不顯示在臉書分享按鈕"> 所有圖像不顯示在臉書分享按鈕 </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-pxgkvrum-ex.html" target="_blank" title="分享按鈕"> 分享按鈕 </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-ctqrozrc-gs.html" target="_blank" title="分享Tweet按鈕現在推特網址"> 分享Tweet按鈕現在推特網址 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-biifugwl-ye.html" target="_blank" title="Facebook分享按鈕等於推特按鈕"> Facebook分享按鈕等於推特按鈕 </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-vzsrmhmy-vn.html" target="_blank" title="臉書視頻下的Facebook分享器"> 臉書視頻下的Facebook分享器 </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-nsmuhvnc-xh.html" target="_blank" title="在臉書上分享HTML內容"> 在臉書上分享HTML內容 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-wgbqjywl-up.html" target="_blank" title="在臉書上分享多張照片"> 在臉書上分享多張照片 </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-yeugcqnt-xd.html" target="_blank" title="在臉書上分享圖片"> 在臉書上分享圖片 </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-uxmcdpuu-bao.html" target="_blank" title="通過臉書分享 - Xcode 4.2與ARC"> 通過臉書分享 - Xcode 4.2與ARC </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-mcziuhox-bme.html" target="_blank" title="通過臉書分享鏈接opengraph api"> 通過臉書分享鏈接opengraph api </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-ychedjtv-bb.html" target="_blank" title="分享按鈕分享所選圖像"> 分享按鈕分享所選圖像 </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-weojhofj-ber.html" target="_blank" title="Twitter分享按鈕動態URL分享"> Twitter分享按鈕動態URL分享 </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-gzjryrfd-cz.html" target="_blank" title="Facebook和Linkedin分享按鈕"> Facebook和Linkedin分享按鈕 </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-ydcdvrlc-uw.html" target="_blank" title="Facebook分享按鈕"> Facebook分享按鈕 </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-syarhftt-u.html" target="_blank" title="Facebook分享按鈕"> Facebook分享按鈕 </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-kyiiclye-dz.html" target="_blank" title="iPhone分享按鈕"> iPhone分享按鈕 </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-udzrmfaf-bbb.html" target="_blank" title="facebook分享按鈕"> facebook分享按鈕 </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-bdxrrtzi-qq.html" target="_blank" title="Facebook分享按鈕"> Facebook分享按鈕 </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-aftjoxex-bax.html" target="_blank" title="Twitter分享按鈕"> Twitter分享按鈕 </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-dnkcqhjc-bcn.html" target="_blank" title="Facebook分享按鈕"> Facebook分享按鈕 </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-reikshns-ne.html" target="_blank" title="Retrofit2中的數據緩存"> Retrofit2中的數據緩存 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-exowneys-nq.html" target="_blank" title="安裝在netstandard 2.0項目中的nuget軟件包中不支持xdt轉換嗎?"> 安裝在netstandard 2.0項目中的nuget軟件包中不支持xdt轉換嗎? </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-vlmdpotc-mm.html" target="_blank" title="從列表中返回MAX值VLOOKUP"> 從列表中返回MAX值VLOOKUP </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-gtkhrmez-ma.html" target="_blank" title="Webassembly的含義是0x40字節?"> Webassembly的含義是0x40字節? </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-ykqgflop-hn.html" target="_blank" title="PHP和Ajax分頁。爲什麼GET方法總是返回空值?"> PHP和Ajax分頁。爲什麼GET方法總是返回空值? </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-dcvvxmba-ke.html" target="_blank" title="添加驗證/如果其他語句公共類功能PHP"> 添加驗證/如果其他語句公共類功能PHP </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-rsdmusnk-cy.html" target="_blank" title="Python:按多列分組的值線圖"> Python:按多列分組的值線圖 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-rcygbhpk-dt.html" target="_blank" title="我不確定如何正確使用fscanf"> 我不確定如何正確使用fscanf </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-rncssdmy-eo.html" target="_blank" title="無法加載資源:服務器與404未找到"> 無法加載資源:服務器與404未找到 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-dohimmzv-gg.html" target="_blank" title="Typescript的/ ** @class * /是否有目的?"> Typescript的/ ** @class * /是否有目的? </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-xslsxynm-cw.html" target="_blank" title="推特/臉書分享動態網址"> 推特/臉書分享動態網址 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-kztpzowj-bmc.html" target="_blank" title="推特按鈕,分享推文"> 推特按鈕,分享推文 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-bsruimcy-uo.html" target="_blank" title="如何與臉書和推特分享照片?"> 如何與臉書和推特分享照片? </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-erhyusyc-hx.html" target="_blank" title="分享臉書的描述"> 分享臉書的描述 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-aphqbnfg-km.html" target="_blank" title="推特「Tweet分享」按鈕不工作"> 推特「Tweet分享」按鈕不工作 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-mvfzufwj-zm.html" target="_blank" title="分享 - 網站中的社交按鈕"> 分享 - 網站中的社交按鈕 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-ftnoepxj-eq.html" target="_blank" title="在https網站上分享按鈕"> 在https網站上分享按鈕 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-pxozusbl-bhk.html" target="_blank" title="網站的Facebook分享按鈕"> 網站的Facebook分享按鈕 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-xfgywrca-bkq.html" target="_blank" title="在臉書上分享帶有圖像的網站內容"> 在臉書上分享帶有圖像的網站內容 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-wnmetytm-rt.html" target="_blank" title="在網站上分享html5視頻到臉書"> 在網站上分享html5視頻到臉書 </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>