|
|
|||||||||||||||
|
|
||||||||||||||||
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I noticed a problem with the above blog tutorial. If you look at the code you can see..
$method = "PFQL.query"; $q = 'SELECT rootid, title FROM root_products WHERE 1 ORDER BY title'; $api_sig = "api_key=".$api_key."method=".$method."query=".$q."session_key=".$sessionID."version=1.0".$secret; $api_sig = md5($api_sig); $q_url = "http://api.printfection.com/restserver.php?api_key=".$api_key."&method=".$method."&query=".$q."&session_key=".$sessionID."&version=1.0&api_sig=".$api_sig; As you can see the query contains spaces, and those spaces are passed directly into the query url. A space in the URL is not acceptable and will cause problems in numerous cases. Per RFC 1738, a space is considered an unsafe character and should not be used in a well formed URL. Ideally this query variable should be changed to this; $q='SELECT%20rootid,%20title%20FROM%20root_products%20WHERE%201%20ORDER%20BY%20title'; I think this will probably solve a lot of peoples problems when experimenting with the Printfection API. |
|
#2
|
|||
|
|||
|
I'm so excited, that I just can't hide it! I was just able to get queries working! The secret is to encode the URL with "%20" instead of spaces but not the md5 hash.
I've been racking my brain for two days now on this issue. So my code looks like this (below). Notice I did change all the variable names with a "pf_" in front of them, so I could easily tell the Printfection variables from the others in my code. $pf_method = "PFQL.query"; $pf_query = 'SELECT rootid, title FROM root_products WHERE 1 ORDER BY title'; $washed_pf_query = str_replace(" ","%20", $pf_query); $pf_api_sig = "api_key=".$pf_api_key."method=".$pf_method."query=".$pf_query."session_key=".$pf_sessionID."version=1.0".$pf_secret_key; $pf_api_sig = md5($pf_api_sig); $pf_query_url = "http://api.printfection.com/restserver.php?api_key=".$pf_api_key."&method=".$pf_method."&query=".$washed_pf_query."&session_key=".$pf_sessionID."&version=".$pf_version."&api_sig=".$pf_api_sig; |
|
#3
|
|||
|
|||
|
I was able to create a simple query which will get the section names and section image_url's for your store.
$pf_storeid = ??????; $pf_query = "SELECT name, image_url FROM store_sections WHERE storeid=".$pf_storeid; The trick was figuring out the $pf_storeid variable. First I tried the name of my store but that didn't work. So to figure out my storeID I did the following. 1. Log into your Printfection store account. 2. From the left side menu select and expand the "My Stores" option 3. Select and expand the storename for the store that you want to run the query for. 4. Select the "Store Settings" menu item. Now go up to the URL for the page that is then loaded. It will look something like this... http://www.printfection.com/account/store_modify.php?storeid=XXXXX&mindex=10 Where the "XXXXX" is a 5 digit number, this is your storeID. So use this to set the $pf_storeid variable like this. $pf_storeid = XXXXX; In your PHP code. Then you should have a query that returns the Section Names and Section Image URL's for all the sections of your store. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with Auth_Token setting in "Building your First Application" blog tutorial | DrPeper | Authentication | 0 | 10-14-2009 02:53 PM |
|