skip to Main Content

So basically I just grab a code from here and test run it.

This is the code:

<?php

$url = "https://230******************dc20:b0817***************008@tr*********s.myshopify.com/admin/customers.json";

$shopcurl = curl_init();
curl_setopt($shopcurl, CURLOPT_URL, $url);
curl_setopt($shopcurl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($shopcurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($shopcurl, CURLOPT_VERBOSE, 0);
curl_setopt($shopcurl, CURLOPT_HEADER, 1);
curl_setopt($shopcurl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($shopcurl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec ($shopcurl);
curl_close ($shopcurl);
echo "<pre>";
print_r($response);

?>

and i get this response:

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 21 Feb 2017 09:24:50 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
X-Frame-Options: DENY
X-ShopId: 17203005
X-ShardId: 4
X-Shopify-Shop-Api-Call-Limit: 1/40
HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40
X-Stats-UserId: 0
X-Stats-ApiClientId: 1529067
X-Stats-ApiPermissionId: 40137419
X-Request-Id: cc57cc1a-da08-4460-bb34-53733b411c6d
Content-Security-Policy: default-src 'self' https://* shopify-pos://*;
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=index&sour
P3P: CP="NOI DSP COR NID ADMa OPTa OUR NOR"
X-Dc: ash
X-Content-Type-Options: nosniff

{"orders":[{"id":4243430853,"email":"[email protected]","closed_at":null,"created_at":"2017-01-31T11:11:05+08:00","updated_...

all I need Is just the last line, And I just don’t know how to remove the other lines.
This tutorial here http://www.codefixup.com/create-app-and-getting-started-with-shopify-api-in-php/ just shows how to connect with the shopify but doesn’t says how. Can anyone help me. Sorry for bad English.

3

Answers


  1. The best way is to use some OOP Wrapper like this one

    It give’s you more control on curl request (headers, body, status code)

    $curl = new CurlCurl();
    $curl->get($url);
    
    if ($curl->error) {
        echo $curl->error_code;
    }
    else {
        echo $curl->response;
    }
    
    Login or Signup to reply.
  2. Just comment out this line

    //curl_setopt($shopcurl, CURLOPT_HEADER, 1);
    

    This was the headers lines you get.

    Login or Signup to reply.
  3. You can also try this one it is workign for me

    <?php header('Access-Control-Allow-Origin: *');
      header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
    $getpage_id=$_REQUEST['page_id']?$_REQUEST['page_id']:"1";
    
    $curl_url="https://71efdddxxxxxxxx:[email protected]/admin/products.json?limit=250&page=".$getpage_id;
    
    $s=file_get_contents($curl_url);
    echo $s;
    ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search