简体   繁体   中英

How to pass variable in url in opencart

Actually,What ever i added in product(image) for admin panel(opencart) that product image automatically should go to pinterest account i have tried but almost done i doing some miner issue i don't know please help me this.

Here my code for controller, 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---------------//

This is pinterest Functionality code: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";

Instead of:

curl_setopt($ch,CURLOPT_POSTFIELDS, 1);

you should pass the post data:

curl_setopt($ch,CURLOPT_POSTFIELDS, $data);

Then, you'll be able to receive the image2 data via $_POST['image2'] in your pintest.php .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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