Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 变量未从配置文件中提取?_Php_Codeigniter_Shopify - Fatal编程技术网

Php 变量未从配置文件中提取?

Php 变量未从配置文件中提取?,php,codeigniter,shopify,Php,Codeigniter,Shopify,我是CodeIgniter的新手,但到目前为止我很喜欢它 我正在通过Shopify API将其移植到CodeIgniter库,但我遇到了一个小问题,我一辈子都无法解决 我得到了一个未定义的变量错误,我觉得这是我缺少的一些非常简单的东西,但我不明白为什么它不起作用。以下是自定义类中的相关代码: class Shopify { public $_api_key; public $_shared_secret; //public $_shops_myshopify_domain; public

我是CodeIgniter的新手,但到目前为止我很喜欢它

我正在通过Shopify API将其移植到CodeIgniter库,但我遇到了一个小问题,我一辈子都无法解决

我得到了一个未定义的变量错误,我觉得这是我缺少的一些非常简单的东西,但我不明白为什么它不起作用。以下是自定义类中的相关代码:

class Shopify
{

public $_api_key;
public $_shared_secret;
//public $_shops_myshopify_domain;



public function __construct ()
{
    $this->_assign_libraries();

    $this->_api_key                     = $this->config->item('api_key', 'shopify');
    $this->_shared_secret               = $this->config->item('shared_secret', 'shopify');
    //$this->_shops_myshopify_domain        =$this->config->item('shops_myshopify_domain', 'bitauth');
}

public function shopify_app_install_url($shop_domain)
{
    return "http://$shop_domain/admin/api/auth?api_key=$_api_key";
}
 public function _assign_libraries()
 {
    if($CI =& get_instance())
    {
        $this->load     = $CI->load;
        $this->config   = $CI->config;

        $this->load->config('shopify', TRUE);

        return;
    }
 }[/code]
以下是我创建的配置文件中的代码:

/**
* Your shared secret
*/
$config['shared_secret'] = 'changed for posting on forum';

/**
* Your Shopify API key
*/
$config['api_key'] = 'changed for posting on forum';
以下是控制器中的相关代码:

    Class shopifyPermission extends CI_Controller {
    function __construct ()
    {
        parent::__construct();

        // Load the Shopify API library
        $this->load->library('shopify.php');
        // Require url helper to perform the header redirect
        $this->load->helper('url');
    }

    function index() {
        //require 'shopify.php';

        $shop_domain = "changed.myshopify.com";

        $url = $this->shopify->shopify_app_install_url($shop_domain);

        //redirect($url);

         $data['url'] = $url;

         $this->load->view('shopifyPermission_view', $data);
    }

}
我得到的错误如下: 遇到一个PHP错误

严重性:通知

消息:未定义变量:\u api\u密钥

文件名:libraries/Shopify.php

电话号码:34


很明显,即使我有一个有效的api密钥,也没有从配置文件中提取api密钥?当我做回显时,它会显示整个URL,但API键不在那里。我不知道该怎么办,如果能得到任何帮助,我将不胜感激!谢谢

您忘记在您的
shopify\u应用程序\u安装\u url()中添加
$this


完美的这正是问题所在。非常感谢你的帮助。
public function shopify_app_install_url($shop_domain)
{
    return "http://$shop_domain/admin/api/auth?api_key={$this->_api_key}";
}