{"_id":"55cbcc534cf2180d00bb1bf4","project":"5436a1e1d0ffee0e00f18f8c","category":{"_id":"54cc2149380ecd0d00ca18b2","project":"5436a1e1d0ffee0e00f18f8c","__v":2,"version":"54cc2148380ecd0d00ca18aa","pages":["54cc2149380ecd0d00ca18bc","54cc2149380ecd0d00ca18bd","54cc2149380ecd0d00ca18be","54cc2149380ecd0d00ca18bf","54cc2149380ecd0d00ca18c0","54cc2149380ecd0d00ca18c1","54cc2149380ecd0d00ca18c2","55cbcc534cf2180d00bb1bf4"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-30T14:26:30.616Z","from_sync":false,"order":7,"slug":"php-client","title":"PHP client"},"user":"5436a1afb7cf0e1c0020d9ca","version":{"_id":"54cc2148380ecd0d00ca18aa","__v":2,"forked_from":"5436a1e1d0ffee0e00f18f8f","project":"5436a1e1d0ffee0e00f18f8c","createdAt":"2015-01-31T00:26:48.753Z","releaseDate":"2015-01-31T00:26:48.753Z","categories":["54cc2149380ecd0d00ca18ab","54cc2149380ecd0d00ca18ac","54cc2149380ecd0d00ca18ad","54cc2149380ecd0d00ca18ae","54cc2149380ecd0d00ca18af","54cc2149380ecd0d00ca18b0","54cc2149380ecd0d00ca18b1","54cc2149380ecd0d00ca18b2","54cc2149380ecd0d00ca18b3","552f29ca633a5b0d00e99d09"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1"},"__v":7,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-08-12T22:44:35.512Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"Not all of ShippingEasy's APIs are available via methods in the library. The ShippingEasy_ApiRequestor class, however, can be used to make requests and it handles the signing of the request with your API key and API secret.\n\nFor example, to create an [EasyShip session](http://shippingeasy.readme.io/docs/partners-api-sessions):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\ninclude './lib/ShippingEasy.php';\\n\\n$secret = \\\"c2286793830dd8bf0f44c2e6b0fd8bed0e95a36d9ca8f0447de9ff5720cd\\\";\\n$apiKey = \\\"ebfef8ffe4aac8d4d8dd4f61b62e871\\\";\\n\\n$method = \\\"post\\\";\\n$path = \\\"/partners/api/sessions\\\";\\n$tmptimestamp = time();\\n$params = array(\\\"api_key\\\" =>  $apiKey, \\\"api_timestamp\\\" => $tmptimestamp);\\n$json_body = array(\\\"session\\\" => array(\\\"email\\\" =>\\n\\\"merchant:::at:::myemail.com\\\", \\\"name\\\" => \\\"Merchant Company Name\\\", \\\"external_identifier\\\"\\n=> \\\"43295\\\"));\\n\\n $sear = new ShippingEasy_ApiRequestor();\\n $res = $sear->request($method, $path, $params, $json_body, $apiKey, $secret);\\n\\n echo \\\"<br/><pre>\\\";\\n print_r($res);\\n echo \\\"</pre><br/><br/>\\\";\\n\\n?>\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nTo access the PDF of an EasyShip shipping label (from the EasyShip [server callback](https://shippingeasy.readme.io/docs/easyship-webhooks)):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\ninclude './lib/ShippingEasy.php';\\n\\n$secret = \\\"c2286793830dd8bf0f44c2e6b0fd8bed0e95a36d9ca8f0447de9ff5720c58d\\\";\\n$apiKey = \\\"ebfef8ffe4aac8d4d8dd4f61b62e871\\\";\\n\\n$method = \\\"get\\\";\\n$path = \\\"/partners/api/labels/4ca622c3a7f2a383c263ee58bfd43b13f288c66b2b63684\\\";\\n$tmptimestamp = time();\\n$params = array(\\\"api_key\\\" =>  $apiKey, \\\"api_timestamp\\\" => $tmptimestamp);\\n\\n $sear = new ShippingEasy_ApiRequestor();\\n $res = $sear->request($method, $path, $params, NULL, $apiKey, $secret);\\n\\n echo \\\"<br/><pre>\\\";\\n print_r($res);\\n echo \\\"</pre><br/><br/>\\\";\\n\\n?>\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nTo create a ShippingEasy account:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\ninclude './lib/ShippingEasy.php';\\n\\n        $secret = \\\"d7ea64a26b6276150e0f8cf06e15df55bfde465de1e870bab143f7978319d2\\\";\\n        $apiKey = \\\"dfaf30a31ed52255f3ef7d0f9ba6216\\\";\\n        $method = \\\"post\\\";\\n       $path = \\\"/partners/api/accounts\\\";\\n\\n        $tmptimestamp = time();\\n        echo \\\"Timestamp: |\\\" . $tmptimestamp . \\\"|<br/><br/>\\\";\\n\\n\\n        $params = array(\\\"api_key\\\" =>  $apiKey, \\\"api_timestamp\\\" => $tmptimestamp);\\n        $json_body = array(\\\"account\\\" => array(\\\"email\\\" => \\\"heberr@kuhlman.net\\\", \\\"first_name\\\" => \\\"Bonita\\\", \\\"last_name\\\" => \\\"Yundt\\\", \\\"company_name\\\" => \\\"Emard, Becker and Morissette\\\", \\\"phone_number\\\" => \\\"7871287490\\\", \\\"address\\\" => \\\"97509 Littel Throughway\\\", \\\"state\\\" => \\\"AA\\\", \\\"postal_code\\\" => \\\"46183\\\", \\\"country\\\" => \\\"Moldova\\\", \\\"password\\\" => \\\"abc123\\\", \\\"subscription_plan_code\\\" => \\\"basic\\\", \\\"city\\\" => \\\"North Marielastad\\\"));\\n\\n         $sear = new ShippingEasy_ApiRequestor();\\n         $res = $sear->request($method, $path, $params, $json_body, $apiKey, $secret);\\n?>\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nTo get the list of stores in a ShippingEasy account:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\ninclude './lib/ShippingEasy.php';\\n\\n    $secret = \\\"52950302eb92883a335ea87df4e2524ba867453d6f1c5e78db2912121\\\";\\n    $apiKey = \\\"55927788798c188a5dd1858eff525a4\\\";\\n    $method = \\\"get\\\";\\n    $path = \\\"/api/stores\\\";\\n\\n     $tmptimestamp = time();\\n \\n     $params = array(\\\"api_key\\\" =>  $apiKey, \\\"api_timestamp\\\" => $tmptimestamp);\\n\\n      $sear = new ShippingEasy_ApiRequestor();\\n      $res = $sear->request($method, $path, NULL, NULL, $apiKey, $secret);\\n\\n      echo \\\"<br/><pre>\\\";\\n      print_r($res);\\n      echo \\\"</pre><br/><br/>\\\";\\n\\n?>\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"accessing-other-apis-1","type":"basic","title":"Accessing Other APIs"}

Accessing Other APIs


Not all of ShippingEasy's APIs are available via methods in the library. The ShippingEasy_ApiRequestor class, however, can be used to make requests and it handles the signing of the request with your API key and API secret. For example, to create an [EasyShip session](http://shippingeasy.readme.io/docs/partners-api-sessions): [block:code] { "codes": [ { "code": "<?php\n\ninclude './lib/ShippingEasy.php';\n\n$secret = \"c2286793830dd8bf0f44c2e6b0fd8bed0e95a36d9ca8f0447de9ff5720cd\";\n$apiKey = \"ebfef8ffe4aac8d4d8dd4f61b62e871\";\n\n$method = \"post\";\n$path = \"/partners/api/sessions\";\n$tmptimestamp = time();\n$params = array(\"api_key\" => $apiKey, \"api_timestamp\" => $tmptimestamp);\n$json_body = array(\"session\" => array(\"email\" =>\n\"merchant@myemail.com\", \"name\" => \"Merchant Company Name\", \"external_identifier\"\n=> \"43295\"));\n\n $sear = new ShippingEasy_ApiRequestor();\n $res = $sear->request($method, $path, $params, $json_body, $apiKey, $secret);\n\n echo \"<br/><pre>\";\n print_r($res);\n echo \"</pre><br/><br/>\";\n\n?>\n", "language": "php" } ] } [/block] To access the PDF of an EasyShip shipping label (from the EasyShip [server callback](https://shippingeasy.readme.io/docs/easyship-webhooks)): [block:code] { "codes": [ { "code": "<?php\n\ninclude './lib/ShippingEasy.php';\n\n$secret = \"c2286793830dd8bf0f44c2e6b0fd8bed0e95a36d9ca8f0447de9ff5720c58d\";\n$apiKey = \"ebfef8ffe4aac8d4d8dd4f61b62e871\";\n\n$method = \"get\";\n$path = \"/partners/api/labels/4ca622c3a7f2a383c263ee58bfd43b13f288c66b2b63684\";\n$tmptimestamp = time();\n$params = array(\"api_key\" => $apiKey, \"api_timestamp\" => $tmptimestamp);\n\n $sear = new ShippingEasy_ApiRequestor();\n $res = $sear->request($method, $path, $params, NULL, $apiKey, $secret);\n\n echo \"<br/><pre>\";\n print_r($res);\n echo \"</pre><br/><br/>\";\n\n?>", "language": "php" } ] } [/block] To create a ShippingEasy account: [block:code] { "codes": [ { "code": "<?php\n\ninclude './lib/ShippingEasy.php';\n\n $secret = \"d7ea64a26b6276150e0f8cf06e15df55bfde465de1e870bab143f7978319d2\";\n $apiKey = \"dfaf30a31ed52255f3ef7d0f9ba6216\";\n $method = \"post\";\n $path = \"/partners/api/accounts\";\n\n $tmptimestamp = time();\n echo \"Timestamp: |\" . $tmptimestamp . \"|<br/><br/>\";\n\n\n $params = array(\"api_key\" => $apiKey, \"api_timestamp\" => $tmptimestamp);\n $json_body = array(\"account\" => array(\"email\" => \"heberr@kuhlman.net\", \"first_name\" => \"Bonita\", \"last_name\" => \"Yundt\", \"company_name\" => \"Emard, Becker and Morissette\", \"phone_number\" => \"7871287490\", \"address\" => \"97509 Littel Throughway\", \"state\" => \"AA\", \"postal_code\" => \"46183\", \"country\" => \"Moldova\", \"password\" => \"abc123\", \"subscription_plan_code\" => \"basic\", \"city\" => \"North Marielastad\"));\n\n $sear = new ShippingEasy_ApiRequestor();\n $res = $sear->request($method, $path, $params, $json_body, $apiKey, $secret);\n?>", "language": "php" } ] } [/block] To get the list of stores in a ShippingEasy account: [block:code] { "codes": [ { "code": "<?php\n\ninclude './lib/ShippingEasy.php';\n\n $secret = \"52950302eb92883a335ea87df4e2524ba867453d6f1c5e78db2912121\";\n $apiKey = \"55927788798c188a5dd1858eff525a4\";\n $method = \"get\";\n $path = \"/api/stores\";\n\n $tmptimestamp = time();\n \n $params = array(\"api_key\" => $apiKey, \"api_timestamp\" => $tmptimestamp);\n\n $sear = new ShippingEasy_ApiRequestor();\n $res = $sear->request($method, $path, NULL, NULL, $apiKey, $secret);\n\n echo \"<br/><pre>\";\n print_r($res);\n echo \"</pre><br/><br/>\";\n\n?>", "language": "php" } ] } [/block]