我需要使用 openbay 中的一个功能连接 eBay 汽车网站,该功能是一个 opencart 扩展。eBay 电机的站点 ID 是 100,但是对于我的生活,我无法通过编写这个函数的方式来改变它,我在这里遗漏了什么吗???
API function call
public function openbay_call($call, array $post = NULL, array $options = array(), $content_type = 'json', $statusOverride = false){
if(defined("HTTPS_CATALOG")){
$domain = HTTPS_CATALOG;
}else{
$domain = HTTPS_SERVER;
}
$data = array(
'token' => $this->token,
'language' => $this->config->get('openbay_language'),
'secret' => $this->secret,
'server' => $this->server,
'domain' => $domain,
'openbay_version' => (int)$this->config->get('openbay_version'),
'data' => $post,
'content_type' => $content_type
);
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $this->url.$call,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1",
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_POSTFIELDS => http_build_query($data, '', "&")
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch)){
$this->log('openbay_call() - Curl Failed '.curl_error($ch).' '.curl_errno($ch));
}
curl_close($ch);
/* There may be some calls we just dont want to log */
if(!in_array($call, $this->noLog)){
$this->log('openbay_call() - Result of : "'.$result.'"');
}
/* JSON RESPONSE */
if($content_type == 'json'){
$encoding = mb_detect_encoding($result);
/* some json data may have BOM due to php not handling types correctly */
if($encoding == 'UTF-8') {
$result = preg_replace('/[^(\x20-\x7F)]*/','', $result);
}
$result = json_decode($result, 1);
$this->lasterror = $result['error'];
$this->lastmsg = $result['msg'];
if(!empty($result['data'])){
return $result['data'];
}else{
return false;
}
/* XML RESPONSE */
}elseif($content_type == 'xml'){
$result = simplexml_load_string($result);
$this->lasterror = $result->error;
$this->lastmsg = $result->msg;
if(!empty($result->data)){
return $result->data;
}else{
return false;
}
}
}else{
$this->log('openbay_call() - OpenBay not active');
$this->log('openbay_call() - Data: '.serialize($post));
}
}
predefined parameters within the class
- 可能无济于事,但无论如何都包括在内。
public function __construct($registry) {
$this->registry = $registry;
$this->token = $this->config->get('openbaypro_token');
$this->secret = $this->config->get('openbaypro_secret');
$this->logging = $this->config->get('openbaypro_logging');
$this->tax = $this->config->get('tax');
$this->server = 1;
$this->lasterror = '';
$this->lastmsg = '';
}
the function call
$this->data['test_category_features'] = $this->ebay->openbay_call('listing/getCategoryFeatures/', array('id' => 35618));
一切正常,但我如何才能将 siteid 更改为 100,我能弄清楚的唯一方法是重新编写我自己的 API 调用类,但客户正在为 openbay 的订阅付费并希望使用 API 调用通过它们,所以我必须使用那里的功能。我试图返回 eBay 电机类别功能,以便他可以像多年来“使用过的零件”一样列出它们。如果您不切换到 eBay 汽车站点 id “100”,那么在尝试通过 opencart 扩展程序将产品添加到 eBay 时,它将不会返回所需的类别变化或更多地接受类别。任何建议将不胜感激,真的卡在这里!提前致谢 :)