Jump to content

Edit History

Sgarbo

Sgarbo

Hello! I've a problem with prestashop 1.7.6.5

On a server, there are two prestashop sites (different websites, not multistore)


One to the public_html/b2b directory - Prestashop 1.6.1.12


One to the public_html/store directory - Prestashop 1.7.6.5

 

it would be www.website.com/b2b and www.website.com/store

Two separate databases also.

I want to add photos to products via webservice. I've a php script for this. 

//image will be associated with product id 4
        $url = "http://www.website.com/b2b/api/images/products/$id_product";

        $ch = curl_init();
        //$cfile = array('image'=>"@".$img_path.";type=image/jpeg");

        #$args['file'] = new CurlFile($img_path);

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        //curl_setopt($ch, CURLOPT_PUT, true);
        curl_setopt($ch, CURLOPT_USERPWD, pr_API_KEY.':');
        curl_setopt($ch, CURLOPT_POSTFIELDS, array('image'=> new CurlFile($img_path)));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $result_curl = curl_exec($ch);
        $errors = curl_error($ch);
        $response = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if($result_curl === false)
          echo "Error $url: $errors\n<br>";
        elseif ($response != 200)
          echo "Error response http $url: $response\n<br>";
        else
          echo "Done: {$api}images/products/$id_product<br />\n<br />\n";

        curl_close($ch);

It, as suggested by prestashop, use the string http: //[email protected]/b2b/api
It works perfectly.

On the second site (PS 1.7.6.5)  instead, if I do the same thing http: //[email protected]/store/api I am redirected to the homepage. Even If I try to writing only  http://mysite.com/store/api I am redirected to homepage....

Could anyone help me understand why? 

Sgarbo

Sgarbo

Hello! I've a problem with prestashop 1.7.6.5

On a server, there are two prestashop sites (different websites, not multistore)


One to the public_html/b2b directory - Prestashop 1.6.1.12


One to the public_html/store directory - Prestashop 1.7.6.5

 

it would be www.website.com/b2b and www.website.com/store

Two separate databases also.

I want to add photos to products via webservice. I've a php script for this. 

//image will be associated with product id 4
        $url = "http://www.website.com/b2b/api/images/products/$id_product";

        $ch = curl_init();
        //$cfile = array('image'=>"@".$img_path.";type=image/jpeg");

        #$args['file'] = new CurlFile($img_path);

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        //curl_setopt($ch, CURLOPT_PUT, true);
        curl_setopt($ch, CURLOPT_USERPWD, pr_API_KEY.':');
        curl_setopt($ch, CURLOPT_POSTFIELDS, array('image'=> new CurlFile($img_path)));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $result_curl = curl_exec($ch);
        $errors = curl_error($ch);
        $response = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        if($result_curl === false)
          echo "Error $url: $errors\n<br>";
        elseif ($response != 200)
          echo "Error response http $url: $response\n<br>";
        else
          echo "Done: {$api}images/products/$id_product<br />\n<br />\n";

        curl_close($ch);

It, as suggested by prestashop, use the string http: //[email protected]/b2b/api
It works perfectly.

On the second site (PS 1.7.6.5)  instead, if I do the same thing http: //[email protected]/store/api I am redirected to the homepage.

 

I manually tried to connect to the webservice of the second store. It only works if the string is http://website.com/api/?ws_key=KEY

 

Could anyone help me understand why? 

×
×
  • Create New...