Я использую Gnome 3 (для моих грехов), который дает мне значок приложения «Эмпатия» в верхней панели моего экрана, когда окно Empathy активно. Щелчок левой кнопкой мыши по имени приложения дает главное меню приложения, в котором есть запись «Номера ...» с элементом «Присоединиться ..». Это вызывает диалог, который я могу использовать, чтобы присоединиться к комнате.
Другим способом было то, что я попытался присоединиться к FreeNode, используя ник, который защищен паролем. Эмпатия подняла уведомление (скрытое от нижней части экрана, я действительно не знаю, что курят эти гномы 3), поэтому, если я навешиваю мышь в нижней части экрана на несколько секунд, нажмите уведомление (возможно, правильно нажмите и выберите «Открыть» в меню). Я нахожу сеанс чата Empathy с именем моего сервера (в моем случае «Freenode»), в который я могу ввести «/ join #whatever».
Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Наконец, я нашел решение!
Были две проблемы:
Теперь, поскольку теперь URL-адрес для содержимого файлов не является URL-адресом api, но https: // files.one.ubuntu.com перед пути к файлу вы должны поместить «путь к контенту / файлу»Что-то вроде этого
oauth-> fetch ('https://files.one .ubuntu.com / содержание / ~ / Ubuntu% 20-он / prova.php ');Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>
$oauth->fetch($api_url.'~/Ubuntu One.'.$filecontentent.'/try.txt', OAUTH_HTTP_METHOD_PUT);
Я думаю, что есть несколько ошибок:
OAUTH_HTTP_METHOD_PUT - это третий аргумент, а не второй для oauth-> fetch () /Ubuntu One.', а не. вы хотели /? содержимое файла, я думаю, должно быть вторым аргументом, поэтому, IMHO, исправленная строка:
$oauth->fetch($api_url.'~/Ubuntu One/try.txt', $filecontentent, OAUTH_HTTP_METHOD_PUT);
(возможно, вы хотите, чтобы в корне, даже $filecontentent, $filecontent)
Проблема заключается в том, что для размещения файла с контентом вам нужно получить «content_path» каталога, в который вы хотите сохранить файл, а затем PUT новый файл под этим content_path. См. Приведенный ниже пример кода, который создает папку ~/Ubuntu One/phptestfolder, получает свой путь content_path и затем выдает файл foo.txt внутри этой вновь созданной папки.
<?php
# Set up OAuth with the token details you've previously saved
$conskey = 'CCCCCC';
$conssec = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS';
$token = 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT';
$secret = 'ssssssssssssssssssssssssssssssssssssssssssssssssss';
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
# Create a folder in Ubuntu One.
# Folders are created by PUTting to the folder path with a PUT body of
# {"kind": "directory"} as explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#put_apifile_storagev1pathtovolumepathtonode
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$oauth->fetch($api_url.'~/Ubuntu%20One/php-test-folder', '{"kind": "directory"}', OAUTH_HTTP_METHOD_PUT);
$response = json_decode($oauth->getLastResponse());
print_r($response);
# So now, we want to upload a file to that new folder. To do that, you need
# to get the directory content path. As explained at
# https://one.ubuntu.com/developer/files/store_files/cloud/#get_apifile_storagev1pathtovolumepathtonode
# "Note that a directory has a content_path. This means that you can PUT a new
# file with content into that directory (see below) by PUTting to
# CONTENT_ROOT + <directory.content-path> + '/' + filename.ext.
# CONTENT_ROOT is the root of the files API itself, /api/file_storage/v1/, but
# temporarily it should be set to https://files.one.ubuntu.com.
# (This note will be removed when this is fixed.)"
# So, we need the directory content path. This is returned in the output from
# the above statement ($oauth->getLastResponse). So, to put a file foo.txt
# with content "this is foo", the URL we need is:
# CONTENT_ROOT: https://files.one.ubuntu.com +
# directory_content_path: $response['content_path'] +
# /: / +
# filename: foo.txt
# We want to urlencode the path (so that the space in "Ubuntu One", for example,
# becomes %20), but not any slashes therein (so the slashes don't become %2F).
# urlencode() encodes spaces as + so we need rawurlencode
$encpath = rawurlencode($response->content_path);
$encpath = str_replace("%2F", "/", $encpath);
$put_file_url = "https://files.one.ubuntu.com" . $encpath . "/" . "foo.txt";
$oauth->fetch($put_file_url, "this is foo", OAUTH_HTTP_METHOD_PUT, array('Content-Type'=>'application/json'));
$response = json_decode($oauth->getLastResponse());
print_r($response);
?>