Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:04:19+00:00 2026-05-30T23:04:19+00:00

So, when I try and run this line of code, I’m getting the following

  • 0

So, when I try and run this line of code, I’m getting the following error:

Fatal error: Call to undefined function curl_http_api_request_() in /Applications/XAMPP/xamppfiles/htdocs/CI/application/libraries/Shopify.php on line 58

Where line 58 is specifically this line:

$response = curl_http_api_request_($method, $url, $query, $payload, $request_headers, $response_headers);

I’m not really sure why it can’t call the second function. The code is below. I’ve got no clue and am at a loss as to what the issue is.

class Shopify
{
public $_api_key;
public $_shared_secret;
public $CI; // To hold the CI superglobal



public function __construct ()
{
    $this->_assign_libraries(); // Loads the CI superglobal and loads the config into it

    // Get values from the CI config
    $this->_api_key                     = $this->CI->config->item('api_key', 'shopify');
    $this->_shared_secret               = $this->CI->config->item('shared_secret', 'shopify');
}

public function shopify_app_install_url($shop_domain)
{
    return "http://$shop_domain/admin/api/auth?api_key=". $this->_api_key;
}


public function shopify_is_app_installed($shop, $t, $timestamp, $signature)
{
    return (md5($this->_shared_secret . "shop={$shop}t={$t}timestamp={$timestamp}") === $signature);
}


public function shopify_api_client($shops_myshopify_domain, $shops_token, $private_app=false)
{
    $password = $private_app ? $this->_shared_secret : md5($this->_shared_secret.$shops_token);
    $baseurl = "https://" . $this->_api_key . ":$password@$shops_myshopify_domain/";

    return function ($method, $path, $params=array(), &$response_headers=array()) use ($baseurl)
    {
        $url = $baseurl.ltrim($path, '/');
        $query = in_array($method, array('GET','DELETE')) ? $params : array();
        $payload = in_array($method, array('POST','PUT')) ? stripslashes(json_encode($params)) : array();
        $request_headers = in_array($method, array('POST','PUT')) ? array("Content-Type: application/json; charset=utf-8", 'Expect:') : array();

        $response = curl_http_api_request_($method, $url, $query, $payload, $request_headers, $response_headers);
        $response = json_decode($response, true);

        if (isset($response['errors']) or ($response_headers['http_status_code'] >= 400))
            throw new ShopifyApiException(compact('method', 'path', 'params', 'response_headers', 'response', 'shops_myshopify_domain', 'shops_token'));

        return (is_array($response) and (count($response) > 0)) ? array_shift($response) : $response;
    };
}

    public function curl_http_api_request_($method, $url, $query='', $payload='', $request_headers=array(), &$response_headers=array())
    {
        $url = curl_append_query_($url, $query);
        $ch = curl_init($url);
        curl_setopts_($ch, $method, $payload, $request_headers);
        $response = curl_exec($ch);
        $errno = curl_errno($ch);
        $error = curl_error($ch);
        curl_close($ch);

        if ($errno) throw new ShopifyCurlException($error, $errno);

        list($message_headers, $message_body) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
        $response_headers = $this->curl_parse_headers_($message_headers);

        return $message_body;
    }

        private function curl_append_query_($url, $query)
        {
            if (empty($query)) return $url;
            if (is_array($query)) return "$url?".http_build_query($query);
            else return "$url?$query";
        }

        private function curl_setopts_($ch, $method, $payload, $request_headers)
        {
            curl_setopt($ch, CURLOPT_HEADER, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_USERAGENT, 'HAC');
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
            curl_setopt($ch, CURLOPT_TIMEOUT, 30);

            if ('GET' == $method)
            {
                curl_setopt($ch, CURLOPT_HTTPGET, true);
            }
            else
            {
                curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $method);
                if (!empty($request_headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
                if (!empty($payload))
                {
                    if (is_array($payload)) $payload = http_build_query($payload);
                    curl_setopt ($ch, CURLOPT_POSTFIELDS, $payload);
                }
            }
        }

        private function curl_parse_headers_($message_headers)
        {
            $header_lines = preg_split("/\r\n|\n|\r/", $message_headers);
            $headers = array();
            list(, $headers['http_status_code'], $headers['http_status_message']) = explode(' ', trim(array_shift($header_lines)), 3);
            foreach ($header_lines as $header_line)
            {
                list($name, $value) = explode(':', $header_line, 2);
                $name = strtolower($name);
                $headers[$name] = trim($value);
            }

            return $headers;
        }


public function shopify_calls_made($response_headers)
{
    return shopify_shop_api_call_limit_param_(0, $response_headers);
}

public function shopify_call_limit($response_headers)
{
    return shopify_shop_api_call_limit_param_(1, $response_headers);
}

public function shopify_calls_left($response_headers)
{
    return shopify_call_limit($response_headers) - shopify_calls_made($response_headers);
}

    private function shopify_shop_api_call_limit_param_($index, $response_headers)
    {
        $params = explode('/', $response_headers['http_x_shopify_shop_api_call_limit']);
        return (int) $params[$index];
    }


/**
 * Shopify::_assign_libraries()
 *
 * Grab everything from the CI superobject that we need
 */
 public function _assign_libraries()
 {

        $this->CI =& get_instance();


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

        return;

 }

UPDATE:
This whole line is started off by me calling this line of code:

$shopify = $this->shopify->shopify_api_client($shops_myshopify_domain, $shops_token);

I have also updated the code above to include the entire file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:04:20+00:00Added an answer on May 30, 2026 at 11:04 pm

    You can achieve it only by passing $this as object to anonymous function, as it has its own context:

    class example {
        public function trigger() {
            $func = $this->func();
            $func($this);
        }
    
        public function func() {
            return function($obj) {
                $obj->inner();
            };
        }
    
        public function inner() {
            die('inside inner');
        }
    }
    
    $obj = new example();
    $obj->trigger();
    

    EDIT: So in response to your problem:

    1. Change this line:

      return function ($method, $path, $params=array(), &$response_headers=array()) use ($baseurl)

    into this:

    return function ($instance, $method, $path, $params=array(), &$response_headers=array()) use ($baseurl)
    
    1. Inside anonymous function change this line:

      $response = curl_http_api_request_($method, $url, $query, $payload, $request_headers, $response_headers);

    into this:

    $response = $instance->curl_http_api_request_($method, $url, $query, $payload, $request_headers, $response_headers);
    
    1. Now shopify_api_client function will return you this ANONYMOUS FUNCTION with no error:

      $shopify = $this->shopify->shopify_api_client($shops_myshopify_domain, $shops_token);

    2. You need to call this function in this way:

      $shopify($this->shopify, … AND HERE THE REST OF ARGUMENTS WHICH ANONYMOUS FUNCTION REQUIRE …);

    Is it clearer now? I have never used shopify, but general way it should work is as I wrote.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to run this page (video.php), I get the following error: Parse
Whenever I try to run this code: #Open file f = open(i.txt, r) line
this error arises when i try to run the following test case which is
I'm receiving the following error on this line of code select.up().appendChild(sw); With error SCRIPT438:
I am getting this error when I try to run this MySQL command: CREATE
I have this Hash Set code and when I try to run my compile
I get an exception on the List.Add line when trying to run this code:
I have run the following code in this page RsyntaxTextArea using Java and i
When I try to run this code Hello World print globals()[__doc__] Why do I
For some reason, when I try to run this code, all I get is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.