protected function build_request($url, $method, $oauth_fields = array(), $exclude_fields = array()) { self::$oauth_fields = array_merge(self::$oauth_fields, $oauth_fields); self::$oauth_fields['oauth_timestamp'] = time(); self::$oauth_fields['oauth_nonce'] = uniqid(); self::$oauth_fields['oauth_signature'] = self::build_signature($url, $method); $this->exclude_fields = $exclude_fields; }
public function list_product($product) { $post_fields = array('Category' => $product['product_category_id'], 'Title' => $product['product_title'], 'Description' => explode("\r\n", $product['product_description']), 'StartPrice' => $product['product_price'], 'Duration' => 7, 'Pickup' => 1, 'ShippingOptions' => array(array('Type' => 1)), 'PaymentMethods' => array(1), 'PhotoIds' => $product['photo_ids']); $headers = array('Content-type: application/json'); $post_fields = json_encode($post_fields); $url = 'https://api.' . self::$url_part . '.co.nz/v1/Selling.json'; $method = 'POST'; parent::build_request($url, $method); $res = parent::do_request($url, $method, $headers, $post_fields); $res[0] = json_decode($res[0], true); if (!array_key_exists('Success', $res[0]) || !$res[0]['Success']) { switch ($res[1]['http_code']) { case self::TM_ERROR_REQUEST: $this->last_error = self::TM_ERROR_REQUEST; break; case self::TM_ERROR_AUTHENTICATION: $this->last_error = self::TM_ERROR_AUTHENTICATION; break; case self::TM_ERROR_RATE_LIMIT: $this->last_error = self::TM_ERROR_RATE_LIMIT; break; case self::TM_ERROR_GENERIC: $this->last_error = self::TM_ERROR_GENERIC; break; } } return $res; }