如何在opencart中传递url中的变量

时间:2018-02-09 07:11:02

标签: php opencart

实际上,我在管理面板(opencart)的产品(图片)中添加了什么产品图像自动应该去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.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";

1 个答案:

答案 0 :(得分:0)

而不是:

curl_setopt($ch,CURLOPT_POSTFIELDS, 1);

你应该传递帖子数据:

curl_setopt($ch,CURLOPT_POSTFIELDS, $data);

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