根据 facebook 的文档,我可以通过以下请求获得我的广告的 HTML 预览片段:
https://graph.facebook.com/CREATIVE_ID/previews?accesstoken=MY_ACCESS_TOKEN
所以我做到了,我得到了这个:
{
"data": [
{
"body": "<div class=\"unclickable\"><div><div class=\"_4u8\" data-ad=\"{"adid":6010408139346,"segment":"market"}\" id=\"6010408139346-id_518a13accaf072305181220\"><div class=\"_24n fbEmuStreamStory fbEmuMarketplace\"><div class=\"clearfix\"><a class=\"_24x _8o _8s lfloat\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>The photo and name of the viewer's friend link to the friend's profile. \\u003Ca target=\\"_blank\\" href=\\"http:\\/\\/www.facebook.com\\/pligor\\">preview\\u003C\\/a>\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\" tabindex=\"-1\" aria-hidden=\"true\"><img class=\"_s0 _54ru img\" src=\"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c6.5.64.64/s32x32/64971_487308981311280_695242760_t.jpg\" alt=\"\" /></a><div class=\"_42ef\"><div class=\"fbEmuMainBody\"><span class=\"uiStream\"><h5 class=\"uiStreamMessage\"><div class=\"actorDescription\"><span class=\"actorName\"><a class=\"actorName firstName _24x\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>The photo and name of the viewer's friend link to the friend's profile. \\u003Ca target=\\"_blank\\" href=\\"http:\\/\\/www.facebook.com\\/pligor\\">preview\\u003C\\/a>\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\">George Pligor</a><i class=\"mhs img sp_5t1i4q sx_c8ea4c\"></i><a class=\"actorName _24x\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>This page\\/application icon and name link to the page\\/application. \\u003Ca target=\\"_blank\\" href=\\"http:\\/\\/www.facebook.com\\/AndroidDevelopersDiscussion?ref=stream\\">preview\\u003C\\/a>\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\">Android Developers</a></span></div> <div class=\"messageBody\"><div class=\"whitespaceLink\" id=\"u_0_0\"><a class=\"_24x\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>Users who click this area will link to the destination specified by this ad. \\u003Ca target=\\"_blank\\" href=\\"\\/AndroidDevelopersDiscussion\\/posts\\/533162160059295\\">preview\\u003C\\/a>.\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\" id=\"u_0_1\"></a>Is this for real?!<br /> <a class=\"_24x\" target=\"_blank\" rel=\"nofollow\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>This clicks through to the webpage liked by the user. \\u003Ca target=\\"_blank\\" href=\\"http:\\/\\/www.facebook.com\\/l.php?u=http\\u00253A\\u00252F\\u00252Fstackoverflow.com\\u00252Fquestions\\u00252F16385364\\u00252Fwhen-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&amp;h=rAQHUwtZv&amp;s=1\\" rel=\\"nofollow\\" onmouseover=\\"LinkshimAsyncLink.swap(this, &quot;http:\\\\\\/\\\\\\/stackoverflow.com\\\\\\/questions\\\\\\/16385364\\\\\\/when-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&quot;);\\" onclick=\\"LinkshimAsyncLink.referrer_log(this, &quot;http:\\\\\\/\\\\\\/stackoverflow.com\\\\\\/questions\\\\\\/16385364\\\\\\/when-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&quot;, &quot;http:\\\\\\/\\\\\\/www.facebook.com\\\\\\/si\\\\\\/ajax\\\\\\/l\\\\\\/render_linkshim_log\\\\\\/?u=http\\\\u00253A\\\\u00252F\\\\u00252Fstackoverflow.com\\\\u00252Fquestions\\\\u00252F16385364\\\\u00252Fwhen-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&amp;h=rAQHUwtZv&amp;s=1&quot;);\\">preview\\u003C\\/a>\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\"><span>http://stackoverflow.com/</span><wbr /><span class=\"word_break\"></span><span>questions/16385364/</span><wbr /><span class=\"word_break\"></span>when-an-activity-binds-an-a</a><a class=\"_24x\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>Users who click this area will link to the destination specified by this ad. \\u003Ca target=\\"_blank\\" href=\\"\\/AndroidDevelopersDiscussion\\/posts\\/533162160059295\\">preview\\u003C\\/a>.\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\">...</a></div></div></h5></span><div class=\"whitespaceLink\" id=\"u_0_2\"><a class=\"_24x\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>Users who click this area will link to the destination specified by this ad. \\u003Ca target=\\"_blank\\" href=\\"\\/AndroidDevelopersDiscussion\\/posts\\/533162160059295\\">preview\\u003C\\/a>.\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\" id=\"u_0_3\"></a><div class=\"mvs plm fbEmuStreamAttachment fbEmuStreamAttachmentOffset textOnly fbEmuStreamBaseStory fbEmuStreamBaseStory\"><a class=\"fbEmuStreamTitle _24x fbEmuStreamLink\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>Users who click this area will link to the destination specified by this ad. \\u003Ca target=\\"_blank\\" href=\\"http:\\/\\/www.facebook.com\\/l.php?u=http\\u00253A\\u00252F\\u00252Fstackoverflow.com\\u00252Fquestions\\u00252F16385364\\u00252Fwhen-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&amp;h=XAQE9ndNZ&amp;s=1\\" rel=\\"nofollow\\" onmouseover=\\"LinkshimAsyncLink.swap(this, &quot;http:\\\\\\/\\\\\\/stackoverflow.com\\\\\\/questions\\\\\\/16385364\\\\\\/when-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&quot;);\\" onclick=\\"LinkshimAsyncLink.referrer_log(this, &quot;http:\\\\\\/\\\\\\/stackoverflow.com\\\\\\/questions\\\\\\/16385364\\\\\\/when-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&quot;, &quot;http:\\\\\\/\\\\\\/www.facebook.com\\\\\\/si\\\\\\/ajax\\\\\\/l\\\\\\/render_linkshim_log\\\\\\/?u=http\\\\u00253A\\\\u00252F\\\\u00252Fstackoverflow.com\\\\u00252Fquestions\\\\u00252F16385364\\\\u00252Fwhen-an-activity-binds-an-already-binded-service-the-onrebind-gets-the-old-inten&amp;h=XAQE9ndNZ&amp;s=1&quot;);\\">preview\\u003C\\/a>.\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\"><div id=\"id_518a13acd3ae61862974322\" class=\"text_exposed_root\">When an activity binds an already binded service<span class=\"text_exposed_hide\">...</span><span class=\"text_exposed_show\"> the onRebind gets the old intent? - Stack Overflow</span><span class=\"text_exposed_hide\"><span class=\"text_exposed_link\"><a onclick=\"CSS.addClass($("id_518a13acd3ae61862974322"), "text_exposed"); Arbiter.inform("reflow");\" data-ft=\"{"tn":"e"}\">See More</a></span></span></div></a></div></div><div class=\"mts fsm fwn fcg\"><div class=\"whitespaceLink\" id=\"u_0_4\"><a class=\"_24x\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>The comment and like icons click through to a page with the original story. \\u003Ca target=\\"_blank\\" href=\\"\\/AndroidDevelopersDiscussion\\/posts\\/533162160059295\\">preview\\u003C\\/a>\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\" id=\"u_0_5\"></a><a class=\"uiBlingBox\" href=\"\" data-ft=\"{"tn":"O"}\" rel=\"async\" ajaxify=\"/ajax/permalink/overlay.php?story_fbid=533162160059295&id=100000965480505&disableego=1&eid=AQL9b9q1T3-bndMGNfqwl7ueBMWsDM7ToQguvrFfxI0vbRYSFFhHDoAMMaZJ2_WaEpqH1KGMmseEc-_c5sFzvSJ5KS_cMvEYArjt6PMKFERuoPUR1PydRr6hSL63YL33saf1AFQUgHqWs7lydjLQyg74SqWPG52EJatOEKbT2uApx8qZnJYFagfLR0vdx9Jezl7yAcMe-PCPr0NmIvt9q9L_0nhjD67DBArKiSm0ZMMS9uuEMjtztsn4_AWIh1pWARDA8mAZJSyL_Nc3kEpF_CTnUiVVcMSp1genwxQbK5J4yvnoyGMeFiYdiZvumJPeyV4238K8Xgwed3Ts3Z2BAlQlrGLKGTjTOaNI52zHxEJi9TyqJQRKoh6yvjnMxWo9kmKo5ylTbC1anDCQL-in8GB-4WRRgq7kUdcRl1Nbz_HVTfUE1nAufOq3d-e_ajX1gwzBOnUlJOcHseuvQz4-KhbcwlOAPo7xgnm77C-oxFu7Q9AKaP0Ca_N2fgmfalGcJtZIWInrOg_OJq72_9m9dSh1uWpdCTiI6aF9KAPjNzJPTOnI-oEZB4P9W2pDRO7coRx80JZti6BtwAcWTOUb1v_X700PmgIc3I10Z2arAoWFakFocxMzHjekyDjaUXVnmmmtZX8NLI7_IR1UWgQXoMi98ijj662eav7g6J1wC95BxDB3GImGQSEDjWkVbMMwI6mvwGAbTwscjSQTkOSsH07VjUvKvEvHJIqSOC2YQDl_xrHqiHcwY0pODekoVFjWB-4VBNQNKVRsxN1kJ1m_bYid9zSroMG3dED7JrhvhWpUPAVfDum9r4XE7HZw6Y16t-26pdLtIvIxcPxEbe0-bRbmhMpyLIR2vUhTG1jhMW_whFfWth5Qg3rwltQl4KEfEcCty_2mq3BMkmk6h_3JUBgQr90u54TDc0tQfR6-W3vr0FsO7RnMAUICFKrfKLr7ucrgltipaiIuk203BiafJOLNaWshte3knvLgRkgZxo42gX6n972nw-TuugfxfwvbTfOSGZQqXOJi2liFhPzkQzFBShfh0v9Lkm09rrSdK8MUGee6d-nLxYKq3Dvmc4p97Lxn9z5--jjDM2NdsM_65-L8-xhH_dL_Gp9zsIvHzsxni442L6-6_XrqJ3os0v8VYIo6jtxHyHBN1Ph07loGfG58x2OLI2BSu-1WE1XauL9XWunQWVhab3hTWKuJjgIJOYY3CcBBQmvwJyuZYKRetMYUD9upcujOOwXH7rQSVC-GKpSHmjuRVCDqtwINJ8OgGVq3CQI6d4t0zxSRt58LdB2K-BmitZMLOYDilGWqSBKvMhW2To507uIrRAD34Bz6nklie4lnAVQeK_mip0yC_RLkR6sxC2cTmi_Zs6V3jxiPL2IvZIhBU406EdMPGsLguNlulScHxgCS7YF1ALAizgwst73jJqnR7v1yx9NABYydaAqEc-VqS3chgZAaw-mEdeJf5jCDzEGaUvV5fCjC-V8-tp7MKiwSPdYykF_bjqmoBElXnNIayaANCCQtGdgxOgjbflXjh22vjqTQKfRndETmmwXtC_oVc9gMlpGTJFnS-bp-plDryuwRXwtakV3OHmQBkveGasTexB6mHnjS5cSwLDZDBXAdnDcT6K55jLI54A&en=fad_strfooteroverlayclick\">Like · Comment</a></div> · <a class=\"_24x\" href=\"#\" onclick=\"new LegacyContextualDialog().init(HTML("\\u003Cdiv class=\\"pam\\">\\u003Cdiv class=\\"mbs fwb\\">Linkable Area\\u003C\\/div>Users who click this area will see a internal dialog window overlay the current page. \\u003Ca href=\\"\\/ajax\\/sharer?s=99&amp;appid=2309869772&amp;p\\u00255B0\\u00255D=100000965480505&amp;p\\u00255B1\\u00255D=533162160059295\\" rel=\\"dialog\\" data-ft=\\"&#123;&quot;tn&quot;:&quot;J&quot;,&quot;type&quot;:25&#125;\\" title=\\"Send this to friends or post it on your timeline.\\" role=\\"button\\">Share\\u003C\\/a>.\\u003C\\/div>")).setWidth(300).setContext(this).enableBehavior(LayerHideOnBlur).disableBehavior(LayerDestroyOnHide).show();\" data-ft=\"{"tn":"J","type":25}\" title=\"Send this to friends or post it on your timeline.\" role=\"button\">Share</a></div></div></div></div></div></div></div><div class=\"unclickableMask\"></div></div>"
}
]
}
我还使用此请求下载了正确的 css:
https://graph.facebook.com/act_MY_ACT_ID/adpreviewscss?accesstoken=MY_ACCESS_TOKEN
并得到:
{我不能把 css 放在这里,因为它很长,但你可以在这里看到它}
但无论我做什么,HTML 看起来都不好。它坏了。
我试过html_entity_decode
and htmlspecialchars_decode
,但没有用。(我在服务器端使用 PHP)
您知道如何使代码段成为有效的 HTML 吗?