Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class EmagController extends AppController {
- /**
- *
- * @var type
- */
- private $_marketplase_url = 'https://marketplace.emag.bg/';
- /**
- *
- * @var type
- */
- private $_marketplase_api_url = 'https://marketplace.emag.bg/api-3';
- /**
- *
- * @var type
- */
- private $_ch;
- /**
- *
- * @var type
- */
- private $_username = 'lancombg';
- /**
- *
- * @var type
- */
- private $_password = 'lancombg123';
- /**
- *
- * @param type $request
- * @param type $response
- */
- public function __construct($request = null, $response = null) {
- $this->_ch = curl_init();
- parent::__construct($request, $response);
- }
- /**
- *
- */
- public function export() {
- echo '<pre>' . print_r($_SERVER, true) . '</pre>';
- $data =
- array(
- 'currentPage' => 1,
- 'itemsPerPage' => 10
- );
- $hash = sha1(http_build_query($data) . sha1($this->_password));
- $requestData = array(
- 'code' => 1,
- 'username' => $this->_username,
- 'data' => $data,
- 'hash' => $hash);
- curl_setopt($this->_ch, CURLOPT_URL, $this->_marketplase_url . 'api-3/category/read');
- curl_setopt($this->_ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($this->_ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($this->_ch, CURLOPT_HEADER, 0);
- curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($this->_ch, CURLOPT_CUSTOMREQUEST, 'POST');
- curl_setopt($this->_ch, CURLOPT_POSTFIELDS, http_build_query($requestData));
- $result = curl_exec($this->_ch);
- echo '<pre>' . print_r(json_decode($result), true) . '</pre>';
- die();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement