Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sample BigCommerce PHP cURL code to update order status with XML response

Featured Replies

Hopefully, this post will help someone trying to integrate their solution with the BigCommerce API.  FileMaker can update the status of an order on BigCommerce by sending a URL to this PHP, transforming a GET call URL to a PUT call for the BigCommerce API v2. The file is hosted on an internal server for security, and requires the cURL library. The key is the curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "PUT"); line to change the normal POST process for adding data into a PUT process for changing data.

 

<?php
	// Converts a GET encoded URL to PUT for BigCommerce API v2.  -Rob Caldwell 3/2013
	// Requires cURL library for PHP on the server.
	// Strongly recommend loading this file on a private internal server for data security.
	// Sample update calculation for FileMaker v10-12 = $php_file_location & "?data=" & Substitute ( GetAsURLEncoded ( "https://user:[email protected]/api/v2/orders/" & $web_order_id & "?<order><status_id>" & $new_order_status & "</status_id></order>" ) ; [ ":" ; "%3A" ] )
	// XML response can be imported directly into FileMaker using an XML stylesheet (XSLT) like the one included in the examples with FileMaker software.
	//
	// You can check any existing order with this simple URL format:
	// "https://user:[email protected]/api/v2/orders/" & $web_order_id
	
	
	/* Authentication not needed if they are included in the url.
	$credentials = "user:apikey";*/
	
	$headers = array( 
		"Content-type: application/xml", 
		//"Authorization: Basic " . base64_encode($credentials) 
	);
	
	$uri = isset($_GET['data']) ? $_GET['data'] : '' ;
	
	if ($uri == "") {
		echo "<html><head><title>Get to Put</title></head><body>
		<div style='text-align:center; padding: 50px 0px;'>
		<form method='get'>
		URL &nbsp;<input type='text' name='data' style='width: 50%'> 
		<INPUT type='submit' value='Put to Update'>
		<form>
		<br /><br />" . htmlentities("Example - https://user:[email protected]/api/v2/orders/100?<order><status_id>10</status_id></order>") . "
		</div>
		</body></html>";
		
	} else {
		
		// Get the current url and split it at the '?'
		$postArray = explode("?", $uri);
		$url = $postArray[0];
		$args = $postArray[1];

		$ch = curl_init($url);  //open connection
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  //optional, sends response to a variable
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);  //set to 60 seconds from BC API Guide v1 PDF example
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  //load all header data
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");  //comment out this PUT line to change to a POST statement
		curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
		
		$result = curl_exec($ch);  //execute post
		
		curl_close($ch);  //close connection
		
		// Quick and dirty output check - if result is XML, make it render nicely in browser
		if (strstr($result, "<?xml") && !strstr($result, "<error>")) header ("content-type: text/xml");
		
		echo $result;
		//echo $uri;
	}
	
?>

 

 

  • 1 year later...
  • Newbies

Hello all!

 

I'm trying to find a way into the whole Filemaker API world for the first time. I'm an experienced Filemaker developer but have only ever worked with self-contained databases.

 

I now have a customer with a BigCommerce store who wants their orders automatically added to their Filemaker order system, and other than exporting CSVs I haven't a clue where to start!

 

I keep reading about accessing PHP APIs using functions in Filemaker but I haven't got the grounding to be able to put things like this suggested solution into practice. I've spent days trawling Google for some kind of Idiots Guide to Working With APIs but no-one seems to write things like this. Are you guys just born with the know-how or something?!

 

Can somebody tell me what I need to know to get started with all this please??

 

Enormous thanks in anticipation,

Daren.

I am puzzled regarding what your question actually is. It seems to me that if you want to import orders from BigCommerce to Filemaker (if that's what you're after), then you need "to find a way into the whole BigCommerce API world" - rather than Filemaker API.

 

With regard to the Filemaker end of this process, I suggest you have a look at:

http://www.filemaker.com/help/13/fmp/en/html/non_toc.46.34.html#1079151

Note that some of the options are new to v.13.

  • Newbies

There you go - I'm so confused I don't even know what I'm asking for!

 

Anyway, thanks for the pointers. I think I've got a handle on which bit does what now.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.