繁体   English   中英

如何在opencart的URL中传递变量

[英]How to pass variable in url in opencart

实际上,我在管理面板(opencart)的product(image)中添加的产品图片应自动转到我尝试过的pinterest帐户,但几乎完成了一些矿工问题,我不知道请帮助我。

这是我的控制器代码product.php:

//--------Post image-------///
       if (isset($this->request->post['image'])) {

                $data['image2'] = $this->request->post['image'];
                //print_r($data['image']);die;
            }
          // print_r($data['image2']);
//--------Post image-------///

 //-------------curl starting---------------//
                $url = 'http://localhost/mspink_new/pintest.php';
                $ch = curl_init();
                curl_setopt($ch,CURLOPT_URL, $url);
                curl_setopt($ch,CURLOPT_POST, count($data['image2']));
                curl_setopt($ch,CURLOPT_POSTFIELDS, 1);
                //execute post
                $result = curl_exec($ch);
                //print_r($result);die;
                curl_close($ch);
//-------------curl clossing---------------//

这是pinterest功能代码:pinterest.php:

<?php

require_once "Pinterest.class.php";
// Create the pinterest object and log in
$p = new Pinterest();
$p->login("me@example.com", "password");
if( $p->is_logged_in() )
    echo "Success, we're logged in\n";

//$image = $p->generate_image_preview("slider-old.jpg");

// if (isset($_POST)) {

//      $image ="image";
// }
// print_r($image);die;
// Set up the pin
//$p->pin_url = "http://yellow5.com";
$p->pin_url = "http://www.mspinkpanther.com/";
$p->pin_description = "My awesome pin";
$p->pin_image_preview = $p->generate_image_preview('slider.jpg');
// Get the boards
$p->get_boards();
// Pin to the board called "Items"
if( !isset($p->boards['Items']) ) {
    echo "For testing, please create a board called 'Items' and try again!\n";
    exit;
}
$p->pin($p->boards['Items']);
// And we're done
echo "Hooray!\n";

代替:

curl_setopt($ch,CURLOPT_POSTFIELDS, 1);

您应该传递帖子数据:

curl_setopt($ch,CURLOPT_POSTFIELDS, $data);

然后,您将能够通过pintest.php $_POST['image2']接收image2数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM