"short lowercase 'group of methods' name", # 'title' => "full title", # 'detail' => "optional extra description", # 'methods' => # [ # 'name' => "optional method name", # 'author' => "optional method author", # 'text' => "mandatory paragraph", # 'explanation' => "optional 'why this does such and such'", # 'note' => "optional 'warning' or 'caution'", # 'example' => "mandatory example", # ] # }; my $method_javascript = { 'text' => "", 'explanation' => "document.write("...."); JavaScript command. p?>', 'example' => <<"EOT", <script language="JavaScript" src="http://www.livejournal.com/customview.cgi?username=[[username]]&amp;styleid=101&amp;enc=js"> <noscript><a href="http://[[username]].livejournal.com/">View my LiveJournal</a></noscript> </script> EOT }; my $method_frameslayers = { 'text' => "www.livejournal.com from the URL and make your journal ". "look like part of your site is using frames... put the HTML page with the ". "<frameset> on your own server, and then make one of the frames be ". "your journal. This method will work with any frame-supporting browser, ". "including Netscape and Internet Explorer. p?>". "<iframe>. Internet Explorer supports this, as do ". "Netscape 6, Mozilla and all recent Opera versions. Inline frames ". "aren't as compatible as normal frames, and won't work in Netscape 4. ". "The following example shows an iframe: p?>", 'note' => "<iframe>, see ". "the HTML 4.0 spec. p?>", 'example' => <<"EOT", <center> <iframe name="livejournal" src="http://www.livejournal.com/users/[[username]]/" frameborder="0" scrolling="auto" height="400" width="460"> <a href="http://[[username]].livejournal.com/">View my LiveJournal</a> </iframe> </center> EOT }; my $method_cgi_script = { 'name' => "Basic CGI Script", 'text' => "", 'explanation' => "www.livejournal.com, because your server is ". "actually the one that's downloading it. p?>", 'note' => "LibWWW module for perl, which you may need to install on your server, ". "or have your admin do it. p?>", 'example' => <<"EOT", #!/usr/bin/perl use LWP::Simple; print "Content-type: text/html\\n\\n"; print get('http://www.livejournal.com/customview.cgi' . '?username=[[username]]&styleid=101'); EOT }; my $method_cgi_ssi = { 'name' => "Server Side Includes and CGI", 'text' => "", 'note' => ".shtml, ". "or set its execute bit; it depends on your webserver and how it's configured. ". "In order to figure that out you might need to talk to your sysadmin. p?>", 'example' => <<"EOT", <!--#exec cgi="/cgi-bin/livejournal.cgi" --> EOT }; my $method_bml = { 'text' => "BML on your server, you need ". "to do two things in your document. First, you need to set the NOCACHE flag (example included), so that the visitor's ". "browser doesn't store old states of the page in cache. Then you simply need to add in the given ". "_CODE block somewhere on your page. p?>\n". "", 'note' => "LibWWW module for Perl, which you may need to install on your server, ". "or have your admin do it. p?>", 'example' => "1\n_info?>\n\n". BML::ehtml(""), }; my $method_python = { 'author' => " Jeremy Tribby", 'text'=> "", 'example' => <<"EOT", <% import urllib u = urllib.open('http://www.livejournal.com/customview.cgi?username=[[username]]&styleid=101') print 'Content-type: text/html\\n\\n' print u.read() %> EOT }; my $method_flash = { 'text' => "One of our users informed us that it is possible to have Flash download a list of ". "variables to prefill into text elements in a Flash file. The formatting of these ". "variable=value pairs are the same as in URLs. To accomodate this need, we provide ". "a style which does this formatting for you. As an example, see the URL below.", 'example' => 'http://www.livejournal.com/customview.cgi?username=[[username]]&styleid=103', }; my $method_php_fpassthru = { 'name' => "Using fpassthru()", 'author' => "Bill Humpries", 'text' => "", 'explanation' => "fopen() to open the journal URL, and then uses fpassthru() ". "to pass the journal content to stdout. p?>", 'example' => <<"EOT", <?php \$journalURL = "http://www.livejournal.com/". "customview.cgi?username=[[username]]&styleid=101"; if (\$fh = fopen(\$journalURL,"r")) { fpassthru(\$fh); } else { echo "<p>Unable to load journal.</p>\\n"; } ?> EOT }; my $method_php_fsockopen = { 'name' => "Using fsockopen()", 'author' => "Elliot Schlegelmilch", 'text' => "", 'explanation' => "fsockopen() to open a network socket to the journal site, and then uses the HTTP protocol to ". "request the journal's content. Given that it doesn't fail, it will simply fetch each line of the server's response. p?>", 'example' => <<"EOT", <?php \$fp = fsockopen("www.livejournal.com", 80, &\$errno, \&\$errstr, 30); if(\$fp) { fputs(\$fp,"GET /customview.cgi?". "username=[[username]]&styleid=101 HTTP/1.0\\n\\n"); while(!feof(\$fp)) { echo fgets(\$fp,128); } fclose(\$fp); } ?> EOT }; my $method_php_file = { 'name' => "Using file()", 'author' => "Jay Cuthrell", 'text' => "This method is useful for those that want a line by line parse of their journal, with line number references.", 'explanation' => "file() function to read in the journal content as a large array, and then it prints ". "it back out line by line. p?>", 'example' => <<"EOT", <?php \$page = "http://www.livejournal.com/customview.cgi". "?username=[[username]]&styleid=101"; \$content = file(\$page); \$slurp = ""; while (list(\$foo,\$bar) = each(\$content)) { \$slurp .= \$bar; } echo \$slurp; ?> EOT }; my $method_php_include = { 'name' => "Using include()", 'author' => "Jon Parise", 'text' => "", 'note' => "", 'example' => <<"EOT", <?php include "http://www.livejournal.com/customview.cgi". "?username=[[username]]&styleid=101"; ?> EOT }; my $method_asp_xmlhttp = { 'name' => "Using the Microsoft.XMLHTTP component", 'author' => "Pavel Titov", 'text' => "Microsoft.XMLHTTP component and IIS. p?>", 'example' => <<"EOT", <% Response.Buffer = True Dim xml ' Create an xmlhttp object: Set xml = Server.CreateObject("Microsoft.XMLHTTP") ' Or, for version 3.0 of XMLHTTP, use: ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP") ' Opens the connection to the remote server. xml.Open "GET", "http://www.livejournal.com/customview.cgi?username=[[username]]&styleid=101", False ' Actually Sends the request and returns the data: xml.Send Response.Write xml.responseText Set xml = Nothing %> EOT }; my $method_asp_perlscript = { 'name' => "Using PerlScript", 'author' => "Ansley Ingram", 'text' => "", 'note' => "ActivePerl ". "installation for NT from ActiveState. p?>", 'example' => <<"EOT", <%\@language=perlscript%> <% use LWP::Simple; \$Response->Write(get 'http://www.livejournal.com/customview.cgi?' . 'username=[[username]]&styleid=101'); %> EOT }; my $method_aolserver = { 'author' => "", 'text' => "", 'note' => "not for people using AOL's Internet Access service; ". "it is for people using the AOLServer web server. p?>", 'example' => <<"EOT", <% ns_puts "[ns_geturl http://www.livejournal.com/customview.cgi?username=[[username]]&styleid=101 ]" %> EOT }; my $method_coldfusion = { 'author' => "", 'text' => "", 'example' => <<"EOT", <CFHTTP URL="http://www.livejournal.com/customview.cgi?username=[[username]]&styleid=101" METHOD="GET"> </CFHTTP> <CFOUTPUT>\#cfhttp.filecontent\#</CFOUTPUT> EOT }; my @methods = ( {'group' => "js", 'title' => "JavaScript", 'detail' => "The easiest way to embed", 'methods' => [$method_javascript], }, {'group' => "frameslayers", 'title' => "HTML Frames", 'detail' => "The next easiest way", 'methods' => [$method_frameslayers], }, {'group' => "cgi", 'title' => "CGI Scripts", 'detail' => "Easy server side programming", 'methods' => [$method_cgi_script, $method_cgi_ssi,], }, {'group' => "bml", 'title' => "Better Markup Language", 'detail' => "Using the language of LiveJournal", 'methods' => [$method_bml], }, {'group' => "flash", 'title' => "Macromedia Flash", 'methods' => [$method_flash], }, {'group' => "php", 'title' => "PHP", 'methods' => [$method_php_fpassthru, $method_php_fsockopen, $method_php_file, $method_php_include], }, {'group' => "python", 'title' => "Python", 'methods' => [$method_python], }, {'group' => "asp", 'title' => "Active Server Pages", 'methods' => [$method_asp_xmlhttp, $method_asp_perlscript], }, {'group' => "coldfusion", 'title' => "Cold Fusion", 'methods' => [$method_coldfusion], }, {'group' => "adp", 'title' => "AOLServer .adp pages", 'methods' => [$method_aolserver], }, ); my $selected_method_group = $FORM{'method'}; my $valid_selection = (defined $selected_method_group and ($selected_method_group eq "all" or grep { $selected_method_group eq $_->{'group'} } @methods)); unless ($valid_selection) { $ret .= <<"EOT"; paid account feature, and so these instructions will not work for users with free accounts. p?> Listed below are some of the different ways that you can embed your journal. view all of the methods on one page. p?> << Back to the developer area EOT $body = $ret; return; } my $remote = LJ::get_remote_noauth(); my $ru=$remote->{'user'} || "username"; my $display_method = sub { my $method = shift; my $heading = (shift() ? "H1" : "H2"); next if not defined $method->{'methods'}; foreach $method (@{$method->{'methods'}}) { if (defined $method->{'name'}) { $ret .="{'name'} $heading?>\n"; } if (defined $method->{'author'}) { $ret .="Contributed by: "; $ret .= $method->{'author'} . " p?>"; } $ret .= "$method->{text}\n"; if (defined $method->{'explanation'}) { $ret .= "$method->{'explanation'}\n"; } if (defined $method->{'note'}) { $ret .= "$method->{'note'}\n"; } my $example=$method->{'example'}; $example=~s/\[\[username\]\]/$ru/gs; $ret .= '
';
         $ret .= $example;
         $ret .= '
'; } }; if ($selected_method_group eq "all") { $title .= " - All Methods"; foreach my $method (@methods) { $ret .= "{'title'} h1?>\n"; $display_method->($method); $ret .= ""; } } else { foreach my $method (@methods) { if ($method->{'group'} eq $selected_method_group) { $title .= " - $method->{'title'}"; # $ret .= "{'title'} h1?>\n"; $display_method->($method,1); $ret .= ""; } } } $ret .= '<< Back to the embedding page'; $body = $ret; return; _code?> body=> page?>