簡體   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