My Account   Shopping Cart   Help

Go Back   Printfection.com > Platform > Authentication
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-14-2009, 03:07 PM
DrPeper DrPeper is offline
Newbie
 
Join Date: Oct 2009
Posts: 11
DrPeper is on a distinguished road
Exclamation Problem with "Part 3 - Getting Information with PFQL" developer blog tutorial.

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.
Reply With Quote
  #2  
Old 10-15-2009, 05:16 PM
DrPeper DrPeper is offline
Newbie
 
Join Date: Oct 2009
Posts: 11
DrPeper is on a distinguished road
Exclamation Got Queries Working!

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;
Reply With Quote
  #3  
Old 10-18-2009, 01:14 PM
DrPeper DrPeper is offline
Newbie
 
Join Date: Oct 2009
Posts: 11
DrPeper is on a distinguished road
Smile Section names and images.

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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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

About Us Blog Community Forums Contact Us Developer Platform Help Site Map

Forums Powered by: vBulletin Version 3.0.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Copyright © 2004-2009 Printfection.com. All rights reserved. Copyright Information. Using this site means you accept its Terms of Service and Privacy Policy.