jasontwong / fetchapp

5 stars 1 forks source link

Blank Page is Showing #3

Open shashankkumrawat opened 9 years ago

shashankkumrawat commented 9 years ago

Hello, I am integrating my custom php website with fetchapp, so I am using this PHP API Module on Github. But it was showing Error "SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed".

Then I followed the instruction given in this Url http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/. Now it is not showing SSL error, but it is showing nothing on page also not creating order in my fetch account. I am using this Simple PHP Wrapper. I am using Windows7, with PHP 5.3.5. Please Help me what is wrong there.?

jasontwong commented 9 years ago

Can you give a snippet of your code? It's been a while since I've used the FetchApp api and it looks like they have a single endpoint for all API requests now. Below is the code I used and I'm getting account information.

// replace $key and $token with your own
$key = 'demokey';
$token = 'demotoken';
$fetch_app = new FetchApp( 'https://app.fetchapp.com', $key, $token );
$account = $fetch_app->account();
var_dump($account);
shashankkumrawat commented 9 years ago

Hi,, thanks for your reply. Here is the code -

include 'Fetchapp.php';

$xml = '<?xml version="1.0" encoding="UTF-8"?>
                 <order>
                    <id>1</id>
                    <vendor_id>1554898798</vendor_id>
                   <first_name>Bugs</first_name>
                   <last_name>Bunny</last_name>
                   <email>bugs@bunny.com</email>
                   <currency>USD</currency>
                   <custom_1>Optional</custom_1>
                   <custom_2>Custom</custom_2>
                   <custom_3>Values</custom_3>
                   <expiration_date type="datetime">2010-09-07T15:08:02+00:00</expiration_date>
                   <download_limit type="integer">5</download_limit>
                   <send_email>true</send_email>
                   <order_items type="array">
                     <order_item>
                        <sku>1</sku>
                        <downloads_remaining type="integer">4</downloads_remaining>
                        <price type="float">4.99</price>
                  </order_item>
               </order_items>
  </order>';

        $fetch_app = new FetchApp( 'https://myname.fetchapp.com', 'myname', 'mytocken' );
        $new_order = simplexml_load_string($xml);
        $order_create_response = $fetch_app->orders('create', $new_order);

But this code not creating any order. However I tried your account inforamtion code which is working fine.

jasontwong commented 9 years ago

Have you tried to var_dump your $order_create_response? When I use your code there is an error response from Fetch.

object(SimpleXMLElement)#3 (1) {
  [0]=>
  string(51) "Order does not contain FetchApp SKUs and is ignored"
}
shashankkumrawat commented 9 years ago

You can see in my above pasted code that I have set sku of product in xml. then why this error is coming.?

jasontwong commented 9 years ago

Can you var_dump your response?

var_dump($order_create_response);
shashankkumrawat commented 9 years ago

yes, I did that and got same error-

object(SimpleXMLElement)#3 (1) { [0]=> string(51) "Order does not contain FetchApp SKUs and is ignored" } 

and if I var_dump() my xml variable i.e. $new_order, I got this-

object(SimpleXMLElement)#2 (13) { ["id"]=> string(1) "1" ["vendor_id"]=> string(10) "1554898798" ["first_name"]=> string(4) "Bugs" ["last_name"]=> string(5) "Bunny" ["email"]=> string(14) "bugs@bunny.com" ["currency"]=> string(3) "USD" ["custom_1"]=> string(8) "Optional" ["custom_2"]=> string(6) "Custom" ["custom_3"]=> string(6) "Values" ["expiration_date"]=> string(25) "2010-09-07T15:08:02+00:00" ["download_limit"]=> string(1) "5" ["send_email"]=> string(4) "true" ["order_items"]=> object(SimpleXMLElement)#4 (2) { ["@attributes"]=> array(1) { ["type"]=> string(5) "array" } ["order_item"]=> object(SimpleXMLElement)#5 (3) { ["skus"]=> string(1) "1" ["downloads_remaining"]=> string(1) "4" ["price"]=> string(4) "4.99" } } }

I have set sku of product in xml. then why this error is coming.?

shashankkumrawat commented 9 years ago

Hello Json,

Have you understood my problem or have you any solution for my problem.? Please let me know soon.

Thanks

jasontwong commented 9 years ago

The SKU id you have in your XML is 1. Do you have a product with that SKU number?

SKU numbers must match one of the products in your account in order to create a valid order with it.

shashankkumrawat commented 9 years ago

I have only one product already created with sku 43324. I am creating new product not updating the existing one, then why should my sku number should match with one of the product in my account.?

Although I changed sku in xml to 43324 and and then checked but still same problem there,

jasontwong commented 9 years ago

According to your code, you are trying to create a new order. A new order requires a valid product SKU. If you want to create a product, you have to change the endpoint and the XML to follow the specs at http://www.fetchapp.com/pages/help-api2