Answer the question
In order to leave comments, you need to log in
How to connect Yandex Disk for a website?
Hello.
There is a need to store some files somewhere. We decided to use Yandex disk for this business I
registered the application on Yandex, received an ID, Password, Callback URL
Downloaded the phar-archive, connected
Everything as here
https://github.com/nixsolutions/yandex-php-library
I do it as in the example here
https ://github.com/nixsolutions/yandex-php-library...
I have a project on CodeIgniter, the code is like this
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
use Yandex\OAuth\OAuthClient;
use Yandex\Disk\DiskClient;
class Test extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index(){
//$this->load->helper('yadisk');
require_once 'phar://yandex-php-library_0.4.0.phar/vendor/autoload.php';
$post=$this->input->post();
if(!empty($post)){
$file = array(
'name' => $_FILES['image']['name'],
'size' => $_FILES['image']['size'],
'path' => $_FILES['image']['tmp_name']
);
//var_dump($_FILES); exit;
$client = $client = new OAuthClient('Тут_мой_ID');
$client->setAccessToken('тут_пароль?');
$token=$client->getAccessToken();
$diskClient = new DiskClient($token );
$diskClient->setServiceScheme(DiskClient::HTTPS_SCHEME);
header('Content-type: application/json');
$result = $diskClient->diskSpaceInfo();
$result['login'] = $diskClient->getLogin();
echo json_encode($result);
}else {
echo "<form action='/test/' method='post' enctype='multipart/form-data'>
<input type='file' name='image'/>
<input type='submit' value='Ok' name='submit'/>
</form>";
}
}
}
Answer the question
In order to leave comments, you need to log in
$client->setAccessToken('password here?');
$client = $client = new OAuthClient('My_ID is here');
$client->setAccessToken('password here?');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question