Web Service无法进行全新安装

时间:2015-01-05 17:26:54

标签: prestashop

在执行Prestashop(v 1.6.0.9)的全新安装后,我遇到了一些关于使web服务功能可用的问题。

我设置了密钥,我可以使用网址检查ws的可用性

http://example.com/webservice/dispatcher.php?ws_key=my_key

其中3个相关结果是:

http://example.com/api/employees?schema=synopsis

http://example.com/api/employees

http://example.com/api/employees?schema=blank

所以,测试上面的链接,我收到消息此页面不可用直接进入我的脸,我不知道为什么会出现这种情况。

对于附加信息,我按照Web Service Tutorial上的步骤将我下载PSWebServiceLibrary.php文件下载到我的根文件夹中,我还创建了一个包含内容的测试文件:

<?php
/**
 * Created by PhpStorm.
 * User: thales.pereira
 * Date: 05/01/15
 * Time: 16:10
 */
require_once( './PSWebServiceLibrary.php' );

$shop_url="http://localhost";
$secret_key="the_key";
$debug=false;
try {
    $webService = new PrestaShopWebservice($shop_url, $secret_key, $debug);

    $opt['resource'] = 'customers?schema=synopsis';
    $xml = $webService->get($opt);
    echo $xml;
}
catch (PrestaShopWebserviceException $ex) {
    echo 'Other error: <br />' . $ex->getMessage();
}

但是......结果是:

Other error:
This call to PrestaShop Web Services failed and returned an HTTP status of 404.
That means: Not Found.

对于这个开发环境,我正在使用MAMP版本3.0.7.3

1 个答案:

答案 0 :(得分:0)

主要问题在于nginx正则表达式规则。

以下是我目前正在使用的内容:

server {

  listen 80;

  server_name 127.0.0.1;
  access_log   /var/log/nginx/prestashop.access.log;
  error_log    /var/log/nginx/prestashop.error.log;
  root /var/www/prestashop;

  if ($http_host != "127.0.0.1") {
    rewrite ^ http://127.0.0.1$request_uri permanent;
  }

  index index.php index.html;

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).

  location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
  }

  rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
  rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last;
  rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
  rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
  rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last;
  rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
  rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 last;

  try_files $uri $uri/ /index.php$is_args$args;

  error_page 404 /index.php?controller=404;

  location ~* \.(gif)$ {
    expires 2592000s;
  }

  location ~* \.(jpeg|jpg)$ {
    expires 2592000s;
  }

  location ~* \.(png)$ {
    expires 2592000s;
  }

  location ~* \.(css)$ {
    expires 604800s;
  }

  location ~* \.(js|jsonp)$ {
    expires 604800s;
  }

  location ~* \.(js)$ {
    expires 604800s;
  }

  location ~* \.(ico)$ {
    expires 31536000s;
  }

  location ~ \.php$ {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
  }

}