Log in

Or connect using:

Embedding LiveJournal - All Methods

JavaScript

The simplest way to embed your journal into your website is to just insert this JavaScript wherever in your webpage HTML that you want your journal to show up. In browsers where JavaScript is unavailable, a link to your journal can be shown instead.

Explanation

This JavaScript fragment loads JavaScript from LiveJournal. The special thing to note here is the &enc=js at the end of the customview.cgi arguments that tells LiveJournal to encode the page as one big document.write("...."); JavaScript command.

<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>

HTML Frames

One way to hide 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.

Additionally, HTML-4.0 compliant browsers are supposed to let you embed a frame inline with your page, so it doesn't have to be on the far side. This is called an <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:

Note

For more information on <iframe>, see the HTML 4.0 spec.

<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>

CGI Scripts

Basic CGI Script

You can write a CGI script (a program that runs on your server) to download your journal and then spit it back out to your clients. You could write a CGI script like this in any language, but by far the easiest language would be Perl, mostly because just about every hosting provider supports it.

Explanation

The client will never see www.livejournal.com, because your server is actually the one that's downloading it.

Note

This example uses the LibWWW module for perl, which you may need to install on your server, or have your admin do it.

#!/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');

Server Side Includes and CGI

If you already have some existing content that you don't want to modify and you just want your LiveJournal inserted into an existing HTML document on your server everytime a client requests it, you can create the CGI script in the previous example and then place the example below into a server-parsed HTML document.

Note

To get an HTML file to be server parsed, you usually have to name it .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.

<!--#exec cgi="/cgi-bin/livejournal.cgi" -->

Better Markup Language

If you're using 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.

Since BML evaluates markup blocks returned from code blocks, you can include BML markup in your embedding style in order to make your embedded journal fit in with your BML scheme.

Note

This uses the LibWWW module for Perl, which you may need to install on your server, or have your admin do it.


<?_code

  use LWP::Simple;
  return get('http://www.livejournal.com/customview.cgi' .
             '?username=username&styleid=101');

_code?>

Macromedia Flash

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.
http://www.livejournal.com/customview.cgi?username=username&styleid=103

PHP

Using fpassthru()

Contributed by: Bill Humpries

This method simply opens the journal URL, and then prints the content.

Explanation

This method uses fopen() to open the journal URL, and then uses fpassthru() to pass the journal content to stdout.

<?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";
}
?>

Using fsockopen()

Contributed by: Elliot Schlegelmilch

This method is slightly different, and may work even if URL fopen wrappers aren't enabled on your server.

Explanation

This method uses 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.

<?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);
}
?>

Using file()

Contributed by: Jay Cuthrell

This method is useful for those that want a line by line parse of their journal, with line number references.

Explanation

This method uses the file() function to read in the journal content as a large array, and then it prints it back out line by line.

<?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;
?>

Using include()

Contributed by: Jon Parise

This simply includes the journal page inside of the PHP page.

Note

This requires you have URL fopen wrappers enabled (they're on by default in PHP 4).

<?php
include "http://www.livejournal.com/customview.cgi".
        "?username=username&styleid=101";
?>

Python

Contributed by: Jeremy Tribby

Embedding your LiveJournal is easy with Python; just use the urllib class.

<%
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()
%>

Active Server Pages

Using the Microsoft.XMLHTTP component

Contributed by: Pavel Titov

This is an easy way to embed your journal using the Microsoft.XMLHTTP component and IIS.

<%
    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
%>

Using PerlScript

Contributed by: Ansley Ingram

Here is how to embed your LiveJournal on your site using ASP and PerlScript.

Note

Unfortuately, many WinNT hosting providers don't offer PerlScript. PerlScript is included in the ActivePerl installation for NT from ActiveState.

<%@language=perlscript%>
<%
    use LWP::Simple;
    $Response->Write(get 'http://www.livejournal.com/customview.cgi?' .
                         'username=username&styleid=101');
%>

Cold Fusion

Contributed by: billythebrick

Cold Fusion users can embed their journals as follows.

<CFHTTP
URL="http://www.livejournal.com/customview.cgi?username=username&styleid=101"
         METHOD="GET">
</CFHTTP>
<CFOUTPUT>#cfhttp.filecontent#</CFOUTPUT>

AOLServer .adp pages

Contributed by: jackal

You can embed your LiveJournal on your site using AOLServer's .adp pages.

Note

This is not for people using AOL's Internet Access service; it is for people using the AOLServer web server.

<%
 ns_puts "[ns_geturl http://www.livejournal.com/customview.cgi?username=username&styleid=101 ]"
%>

<< Back to the embedding page

Welcome to the new LiveJournal

Some changes have been made to LiveJournal, and we hope you enjoy them! As we continue to improve the site on a daily basis to make your experience here better and faster, we would greatly appreciate your feedback about these changes. Please let us know what we can do for you!

Send feedback

Switch back to old version

LiveJournal Feedback

See a bug? Let us know! Here you can also share your thoughts and ideas about updates to LiveJournal

Your request has been filed. You can track the progress of your request at:
If you have any other questions or comments, you can add them to that request at any time.

Send another report Close feedback form

If you're a LiveJournal user, you will be logged in after submitting your request.

(optional, if you're a LiveJournal user only)

(optional, if you're a LiveJournal user only)

(not shown to the public)

If you have a billing inquiry, please go here to submit your question.

Provide a link to the page where you are experiencing the error

Do not include any sensitive information, such as your password or phone number. No HTML allowed.

If you can't pass the human test, email your inquiry to: support@livejournal.com