Noobie bigcommerce API connection

前端 未结 5 1899
粉色の甜心
粉色の甜心 2021-01-22 22:21

Sorry for the noobie question but I just wanted to know the process by which I could at least connect to my bigcommerce store and query it via a PHP or curl script.

If s

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-22 22:58

    Simple cURL snippet to get orders

    $api_url = 'https://YOUR-API-PATH.mybigcommerce.com/api/v2/orders.json';
    
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $api_url );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array ('Accept: application/json', 'Content-Length: 0') );
    curl_setopt( $ch, CURLOPT_VERBOSE, 0 );
    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt( $ch, CURLOPT_USERPWD, "YOUR-USERNAME:YOUR-API-TOKEN" );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
    
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    
    $response = curl_exec( $ch );
    
    $result = json_decode($response);
    print_r($result);
    

    Hope this helps

提交回复
热议问题