cloudfiles远程文件问题

I am trying to load a file to my Cloud Files Container from a remote file.

Below is the example code a Cloud Files Support person gave me:

<?php

    require('cloud/cloudfiles.php');

    $res  = fopen("http://images.piccsy.com/cache/images/66653-d71e1b-320-469.jpg", "rb");
    $temp = tmpfile();
    $size = 0.0;
    while (!feof($res))
    {
        $bytes = fread($res, 1024);
        fwrite($temp, $bytes);
        $size += (float) strlen($bytes);
    }

    fclose($res);
    fseek($temp, 0);

    //
    $auth = new CF_Authentication('user','token ');
    //Calling the Authenticate method returns a valid storage token and allows you to connect to the CloudFiles Platform.
    $auth->authenticate();

    $conn = new CF_Connection($auth);

    $container = $conn->create_container("example");
    $object = $container->create_object("example.jpg");
    $object->content_type = "image/jpeg";
    $object->write($temp, $size);

    fclose($temp);
?>

The problem I am getting is the below error:

Fatal error: Call to a member function create_container() on a non-object in /home2/sharingi/public_html/daily_dose/remote_test.php on line 24

Not sure exactly what I am not noticing here.

It seems $conn did not successfully instantiate an object. That is the problem, but the solution is not clear cut.

Is CF_Connection defined? Does error_reporting(E_ALL) give you more helpful info? What does var_dump($conn instanceof CF_Connection) output?

This should point you in the right direction.