Tips and Tricks HQ Support Portal › Forums › WP PDF Stamper › HTTP POST Method Won't Work
Tagged: HTTP Post, WP PDF Stamper
- This topic has 7 replies, 2 voices, and was last updated 14 years, 1 month ago by thpwebteam.
-
AuthorPosts
-
September 30, 2010 at 4:18 pm #1945thpwebteamMember
Greetings,
I was able to get the “Manual Stamping” to work as well as the HTTP GET method. However, I have not been successfully able to get the HTTP Post method to work even though I’m using the same parameters as the GET method.
I don’t get any errors from the sample HTTP Post sample code. All it returns is:
“An error occured while trying to stamp the file! Error details: “
Any ideas?
October 1, 2010 at 1:14 am #24936amin007ParticipantMaybe some mandatory parameter is missing. Can you please tell how you are trying to use it? Please provide the code you are using so I can have a look.
What is your PDF stamper version?
October 1, 2010 at 1:21 pm #24937thpwebteamMemberI basically took the code below, put it in a php file, placed the file in the root, and ran it from the browser.
<?
/*** Mandatory data ***/
// Post URL (Get this value from the Integration Help menu of this plugin)
$postURL = "http://www.webdev4.com/wp-content/plugins/wp-pdf-stamp/api/stamp_api.php";
// The Secret key (Get this value from the settings menu of this plugin)
$secretKey = "4ca4929b783ec5.15678014"; //not actual for security purposes
//The source file URL (The file that you want to stamp)
$fileURL = "http://www.webdev4.com/wp-content/uploads/fw4.pdf";
/*** Optional Data ***/
//Customers Name
$customerName = "John Doe";
//Customer Email address
$customerEmail = "john.doe@gmail.com";
//Customer's Address
$customerAddress = "123 Some Street, San Jose, CA - 95130, U.S.A.";
// prepare the data
$data = array ();
$data['secret_key'] = $secretKey;
$data['source_file'] = $fileURL;
$data['customer_name'] = $customerName;
$data['customer_email'] = $customerEmail;
$data['customer_address'] = $customerAddress;
// send data to post URL
$ch = curl_init ($postURL);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returnValue = curl_exec ($ch);
// Process the return values
list ($status, $value) = explode ("n", $returnValue);
if(strpos($status,"Success!") !== false)
{
$file_url = trim($value);
echo "The URL of the stamped file is: ".$file_url;
}
else
{
echo "An error occured while trying to stamp the file! Error details: ".$value;
}
?>October 2, 2010 at 2:28 am #24938amin007ParticipantThanks for sharing the code… I see the issue now
The POST URL is incorrect (it’s giving a 404)
$postURL = "http://www.webdev4.com/wp-content/plugins/wp-pdf-stamp/api/stamp_api.php";
If you read the comment above that line you will see that it tells you to get this value from the “Integration Help” menu of this plugin. So go ahead and do that and let me know how it goes.
October 4, 2010 at 4:38 pm #24939thpwebteamMemberThe URL that I used is from the Integration Menu. See screenshot:
http://www.tyndale.com/external_parties/pics/tipsandtricks_techsupport/integration_help.jpg
I also checked that file on the web-server and it is correct.
If you try to type in the URL you will get a 404. The domain is setup internally on our development web server.
October 4, 2010 at 4:43 pm #24940thpwebteamMemberAlso, note that if I use the GET request it works. So something like this works:
http://www.webdev4.com/wp-content/plugins/wp-pdf-stamper/api/stamp_api.php?secret_key=4ca4929b783ec5.XXXXXXXX&source_file=http://www.webdev4.com/wp-content/uploads/fw4.pdf&customer_name=jon doe&customer_email=jon.doe@gmail.com&customer_address=123 Some Street, San Jose, CA – 95130, U.S.A
Post is failing, no PDF is being stamped and I’m not getting any errors.
October 5, 2010 at 2:16 am #24941amin007ParticipantSorry, I should have been more specific. If you look at the screenshot again you will see the URL actually has the following:
wp-pdf-stamper
Not “wp-pdf-stamp” which has been used in the code. See the “er” at the end of the word? That’s making the URL a non-existent URL.
Let me know if that helps.
October 5, 2010 at 3:43 pm #24942thpwebteamMemberBrilliant! I’m not even sure how I missed something like that! Thank you so much!
-
AuthorPosts
- You must be logged in to reply to this topic.