• Resolved jayala87

    (@jayala87)


    Hello!

    i am trying to import products from an external source into woocommerce. I would like to store all those products into our wordpress instance. We are given an api but that CRM product api requires authentication and another id in order for me to get the json (before i was just able to get the json from their old api url now it requires authentication.)

    the documentation for their APi is here: https://code.treez.io/reference#product_api-beta

    as you can see it requires me to authenticate and use a client ID. previously i was just able to use the json feed form their URL and import using the All Import wordpress plug-in.

    I don’t know if i can pass the authorization and client id via a url..it looks like i need to use cURL. how would i go about this? I know woocommerce has its own API but how would i get Product API from the external CRM to integrate with WooCommerce’s api? Any suggestions, direction would help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @jayala87 I think this code will solve your problem you have to just enter the client id in the and authorization it will give the result.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://api.treez.io/v2.0/dispensary/partnersandbox2/product/product_list?category_type=all&page=1&pagesize=50&active=true");
    
    $headers = array();
    $headers[] = 'authorization: authorization';
    $headers[] = 'client_id: client_id';
    curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
    $server_output = curl_exec ($ch);
    
    curl_close ($ch);
    
    print  $server_output ;
    
    
    Thread Starter jayala87

    (@jayala87)

    @mohitmishra Do i put this in the functions.php file?

    @jayala87 Yes you can put it on the functions.php file then you will be able to get the results of the API.

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any further questions!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Import external products into woocommerce using API’ is closed to new replies.