Question: I am migrating my Facebook canvas application to using the new PHP SDK. However, I am having a problem getting the JavaScript SDK to work too.

I'm wanting to take advantage of methods such as `stream.publish` in the JavaScript SDK. Unfortunately I've not been able to get anything to work thus far. I have the following in the header of my application's `index.php` file:

```
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_GB/all.js"></script>
<script>
    FB.init({appId: *);
    FB.ui({
        method: 'stream.publish',
        message: 'Check out this great app!'
    });
</script>

```

My application ID has been removed for obvious reasons.

Where I'd expect the above to give the user a prompt to publish a message to their stream, it's not. Can I even use the new JavaScript SDK in Facebook canvas applications? Or is it reserved for iFrame applications and utilizing Facebook Connect on websites only?

Answer: 
Try `$path = '/images/imagename.jpg;` that way you're are referencing from the document root path.
`file_exists` should check for existance of file in filesystem, while html images should use url (whether they are relative or absolute). There should be no confusion between to, and as you noticed it using same variable for both could lead to issues.

You can use some constants to define you application root path. If you use a front controller at the root dir of your project 

```
define('APP_PATH', dirname(__FILE__));

```

Or you can use little helper functions to get your image path and url separately, something to use in your view/template files

```
get_image_path($fileName);
get_image_uri($fileName);

```

this way you can easily move images files elsewhere and keep your existants url the same, or change urls without actually moving files in file system.