...

View Full Version : trying to figure out how to embed a ss script onto another webpage



Bobafart
03-01-2008, 03:39 PM
I am trying to make a free link exchange script. I have created a server side script. The URL of this script is:

http://www.foo.com/promotion/linkexchange/ssi.php

it parses RSS feeds and outputs them in javascript. An example of the output is:



document.write('<div>');
document.write('<p><a href="http://feeds.engadget.com/~r/weblogsinc/engadget/~3/243890798/">Telsa sets the record straight: Roadster has airbags, okay?</a></p>');
document.write('<p>Filed under: <a href="http://www.engadget.com/category/transportation/" rel="tag">Transportation</a></p><div align="center"><a href="http://www.teslamotors.com/blog3/?p=73"><img vspace="4" hspace="4" border="1" src="http://www.blogsmithmedia.com/www.engadget.com/media/2008/01/1-25-08-tesla-roadster-smashed.jpg" alt="" /></a><br /></div>
Tesla VP of Vice President of Sales, Marketing, and Service, Darryl Siry, set the record straight on the whole <a href="http://www.engadget.com/2008/01/29/tesla-roadster-gets-air-bag-waiver-for-green-behavior/">airbag wavier thing</a>: in case it wasn't already clear, the Roadster does indeed have driver and passenger airbags. The waiver was regarding the fact that currently "front passenger airbag does not vary its deployment based on the weight of the passenger," and thus needed the waiver not unlike other boutique automakers (he cites the Ferrari F430 as an example). Of course, this misunderstandings and misinformation might have been mitigated if Telsa just addressed the issue at the time (instead of waiting a month after the fact); we can only hope their non-metaphoric airbags don't take as long to deploy.<p>&nbsp;</p><p><a href="http://www.teslamotors.com/blog3/?p=73">Read</a> | <a href="http://www.engadget.com/2008/03/01/telsa-sets-the-record-straight-roadster-has-airbags-okay/" rel="bookmark" title="Permanent link to this entry">Permalink</a> | <a href="http://www.engadget.com/forward/1128742/" title="Send this entry to a friend via email">Email this</a> | <a href="http://www.engadget.com/2008/03/01/telsa-sets-the-record-straight-roadster-has-airbags-okay/#comments" title="View reader comments on this entry">Comments</a></p><hr />
<p><a href="http://feeds.engadget.com/~a/weblogsinc/engadget?a=Oel7ny"><img src="http://feeds.engadget.com/~a/weblogsinc/engadget?i=Oel7ny" border="0"></img></a></p><div>
<a href="http://feeds.engadget.com/~f/weblogsinc/engadget?a=5b1D09f"><img src="http://feeds.engadget.com/~f/weblogsinc/engadget?i=5b1D09f" border="0"></img></a> <a href="http://feeds.engadget.com/~f/weblogsinc/engadget?a=gyLe0if"><img src="http://feeds.engadget.com/~f/weblogsinc/engadget?i=gyLe0if" border="0"></img></a>
</div><img src="http://feeds.engadget.com/~r/weblogsinc/engadget/~4/243890798" height="1" width="1" />');
document.write('<p>Source: <a href="http://www.engadget.com">Engadget</a></p>');
document.write('</div>');
document.write('<div>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/afp/20080301/ts_afp/britainroyalsafghanistanmilitary">Prince Harry back in Britain after Afghan tour
(AFP)</a></p>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/afp/20080301/ts_afp/britainroyalsafghanistanmilitary"><img src="http://d.yimg.com/us.yimg.com/p/afp/20080301/capt.cps.mmx69.010308152940.photo00.photo.default-330x512.jpg?x=83&amp;y=130&amp;q=85&amp;sig=rY.Hal6Abrbe2xorM4n6iA--" align="left" height="130" width="83" alt="Prince Harry in the desert in Helmand province on February 18. Harry has returned to Britain from Afghanistan after a 10-week tour fighting the Taliban, to be reunited with his father Prince Charles and elder brother Prince William.(AFP/POOL/File/John Stillwell)" border="0" /></a>AFP - Prince Harry returned to Britain from Afghanistan Saturday after a 10-week tour fighting the Taliban, to be reunited with his father Prince Charles and elder brother Prince William.</p><br clear="all"/>');
document.write('<p>Source: <a href="http://news.yahoo.com/i/716">Yahoo! News: Top Stories</a></p>');
document.write('</div>');
document.write('<div>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20080301/ap_on_re_mi_ea/israel_palestinians">Israeli-Palestinian clashes kill 33
(AP)</a></p>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20080301/ap_on_re_mi_ea/israel_palestinians"><img src="http://d.yimg.com/us.yimg.com/p/ap/20080301/capt.akcf10303010946.mideast_israel_palestinians_akcf103.jpg?x=130&amp;y=92&amp;q=85&amp;sig=4BsCLTaEJqvUzWNtAoO qPA--" align="left" height="92" width="130" alt="Palestinian Hamas militants take position next to a burning barricade during an Israeli army operation east of Jebaliya, in the northern Gaza Strip, Saturday, March 1, 2008. Twenty-one Palestinians, including at least eight civilians, were killed late Friday and early Saturday in escalating Israeli-Palestinian fighting that renewed threats of an Israeli invasion of Gaza and clouded peace efforts. A baby and two teenagers were among the dead, and dozens of people were wounded, Palestinian medical sources said.(AP Photo/Ashraf Amra)" border="0" /></a>AP - Palestinians threatened Saturday to call off peace talks with Israel after 33 Gazans, at least half of them civilians, were killed in violence that escalated sharply during the day.</p><br clear="all"/>');
document.write('<p>Source: <a href="http://news.yahoo.com/i/716">Yahoo! News: Top Stories</a></p>');
document.write('</div>');
document.write('<div>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20080301/ap_on_re_mi_ea/turkey_iraq">Gen: Turkish pullout had been planned
(AP)</a></p>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20080301/ap_on_re_mi_ea/turkey_iraq"><img src="http://d.yimg.com/us.yimg.com/p/ap/20080229/capt.xbo15102291928.turkey_iraq_xbo151.jpg?x=130&amp;y=87&amp;q=85&amp;sig=q8kqL9_jsnwPRXBTBeLveg--" align="left" height="87" width="130" alt="Turkish army trucks carrying commandos return from northern Iraq, in Cukurca in Hakkari province at the Turkey-Iraq border, Friday, Feb. 29, 2008. Hundreds of military trucks carried Turkish troops back home from neighboring Iraq on Friday. (AP Photo/Burhan Ozbilici)" border="0" /></a>AP - Turkey's top general said the country's troop withdrawal from Iraq had nothing to do with U.S. calls to keep the cross-border campaign against Kurdish rebels as short as possible, a newspaper reported Saturday.</p><br clear="all"/>');
document.write('<p>Source: <a href="http://news.yahoo.com/i/716">Yahoo! News: Top Stories</a></p>');
document.write('</div>');
document.write('<div>');
document.write('<p><a href="http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/nm/20080301/ts_nm/britain_harry_dc">Prince Harry back from Afghan frontline
(Reuters)</a></p>');



User can then cut and paste the following code onto their website:

<script type="text/javascript" source="http://www.foo.com/promotion/linkexchange/ssi.php">


The intention is to have the above javascript display on their website. The problem is, when I try this nothing outputs so I am obviously doing something wrong.

Please help. This is the first time I am doing this...

Bobafart
03-01-2008, 03:42 PM
my bad... never though of enabling firebug.. posted here too quickly..

firebug has a problem with the 3rd line:


unterminated string literal



document.write('<p>Filed under: <a href="http://www.engadget.com/category/transportation/" rel="tag">Transportation</a></p><div align="center"><a href="http://www.teslamotors.com/blog3/?p=73"><img vspace="4" hspace="4" border="1" src="http://www.blogsmithmedia.com/www.engadget.com/media/2008/01/1-25-08-tesla-roadster-smashed.jpg" alt="" /></a><br /></div>

Bobafart
03-01-2008, 03:44 PM
it must be the " wasn't " apostrophe

anyone know how to escape ' when using



document.write('<?php echo $item->get_content(); ?>');


html_specialchars??

gsnedders
03-01-2008, 04:03 PM
The following would work:

<?php echo htmlspecialchars($item->get_content, ENT_QUOTES, 'UTF-8'); ?>

Bobafart
03-01-2008, 09:44 PM
gsnedders rocks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum