Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. public function index2()
  2. {
  3. $consumerKey = 'kfkhypveth1upv6f4uwy5l9r7tdwmdp0';
  4. $consumerSecret = 't9ire4rup8wre5gbbqt3ic2q2snb6ogs';
  5. $accessToken = '9alfh5bntatd0gk3lwdjxv972erppnmk';
  6. $accessTokenSecret = 'rxmvwjrb9r8qq2hy0e2ijdytk2srrhmc';
  7. $method = 'GET';
  8. $status_field = "searchCriteria[filterGroups][0][filters][0][field]=status";
  9. $status_value = "searchCriteria[filterGroups][0][filters][0][value]=pending";//
  10. $status_condition = "searchCriteria[filterGroups][0][filters][0][condition_type]=eq";
  11. $sc = $status_field . '&' . $status_value . '&' . $status_condition;
  12.  
  13. $url = "http://127.0.0.1:8080/mg1/index.php/rest/V1/orders/?".$sc;
  14.  
  15. $data = [
  16. 'oauth_consumer_key' => $consumerKey,
  17. 'oauth_nonce' => md5(uniqid(rand(), true)),
  18. 'oauth_signature_method' => 'HMAC-SHA1',
  19. 'oauth_timestamp' => time(),
  20. 'oauth_token' => $accessToken,
  21. 'oauth_version' => '1.0',
  22. ];
  23.  
  24. $data['oauth_signature'] = $this->sign($method, $url, $data, $consumerSecret, $accessTokenSecret);
  25. $curl = curl_init();
  26. curl_setopt_array($curl, [
  27. CURLOPT_RETURNTRANSFER => 1,
  28. CURLOPT_URL => $url,
  29. CURLOPT_HTTPHEADER => [
  30. 'Authorization: OAuth ' . http_build_query($data, '', ',')
  31. ]
  32. ]);
  33.  
  34. $result = curl_exec($curl);
  35. curl_close($curl);
  36. echo '<pre>';
  37. print_r(json_decode($result,false));
  38.  
  39.  
  40. }//end of function
  41.  
  42. stdClass Object
  43. (
  44. [message] => Invalid signature
  45. [trace] => #0 C:wamp64wwwmg1vendormagentoframeworkOauthOauth.php(121): MagentoFrameworkOauthOauth->_validateSignature(Array, 't9ire4rup8wre5g...', 'GET', 'http://127.0.0....', 'rxmvwjrb9r8qq2h...')
  46. #1 C:wamp64wwwmg1vendormagentomodule-webapiModelAuthorizationOauthUserContext.php(82): MagentoFrameworkOauthOauth->validateAccessTokenRequest(Array, 'http://127.0.0....', 'GET')
  47. #2 C:wamp64wwwmg1vendormagentomodule-authorizationModelCompositeUserContext.php(78): MagentoWebapiModelAuthorizationOauthUserContext->getUserId()
  48. #3 C:wamp64wwwmg1vendormagentomodule-authorizationModelCompositeUserContext.php(57): MagentoAuthorizationModelCompositeUserContext->getUserContext()
  49. #4 C:wamp64wwwmg1vendormagentomodule-webapiModelWebapiRoleLocator.php(45): MagentoAuthorizationModelCompositeUserContext->getUserId()
  50. #5 C:wamp64wwwmg1vendormagentoframeworkAuthorization.php(47): MagentoWebapiModelWebapiRoleLocator->getAclRoleId()
  51. #6 C:wamp64wwwmg1vendormagentoframeworkInterceptionInterceptor.php(74): MagentoFrameworkAuthorization->isAllowed('Magento_Sales::...', NULL)
  52. #7 C:wamp64wwwmg1vendormagentoframeworkInterceptionChainChain.php(70): MagentoFrameworkAuthorizationInterceptor->___callParent('isAllowed', Array)
  53. #8 C:wamp64wwwmg1vendormagentoframeworkInterceptionChainChain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Magento\Framewo...', 'isAllowed', Object(MagentoFrameworkAuthorizationInterceptor), Array, 'customerAuthori...')
  54. #9 C:wamp64wwwmg1vendormagentomodule-customerModelPluginCustomerAuthorization.php(58): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChain{closure}('Magento_Sales::...', NULL)
  55. #10 C:wamp64wwwmg1vendormagentoframeworkInterceptionChainChain.php(67): MagentoCustomerModelPluginCustomerAuthorization->aroundIsAllowed(Object(MagentoFrameworkAuthorizationInterceptor), Object(Closure), 'Magento_Sales::...', NULL)
  56. #11 C:wamp64wwwmg1vendormagentoframeworkInterceptionInterceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Magento\Framewo...', 'isAllowed', Object(MagentoFrameworkAuthorizationInterceptor), Array, 'guestAuthorizat...')
  57. #12 C:wamp64wwwmg1vendormagentomodule-webapiModelPluginGuestAuthorization.php(38): MagentoFrameworkAuthorizationInterceptor->MagentoFrameworkInterception{closure}('Magento_Sales::...', NULL)
  58. #13 C:wamp64wwwmg1vendormagentoframeworkInterceptionInterceptor.php(142): MagentoWebapiModelPluginGuestAuthorization->aroundIsAllowed(Object(MagentoFrameworkAuthorizationInterceptor), Object(Closure), 'Magento_Sales::...')
  59. #14 C:wamp64wwwmg1vargenerationMagentoFrameworkAuthorizationInterceptor.php(26): MagentoFrameworkAuthorizationInterceptor->___callPlugins('isAllowed', Array, Array)
  60. #15 C:wamp64wwwmg1vendormagentoframeworkWebapiAuthorization.php(37): MagentoFrameworkAuthorizationInterceptor->isAllowed('Magento_Sales::...')
  61. #16 C:wamp64wwwmg1vendormagentomodule-webapiControllerRestRequestValidator.php(86): MagentoFrameworkWebapiAuthorization->isAllowed(Array)
  62. #17 C:wamp64wwwmg1vendormagentomodule-webapiControllerRestRequestValidator.php(70): MagentoWebapiControllerRestRequestValidator->checkPermissions()
  63. #18 C:wamp64wwwmg1vendormagentomodule-webapiControllerRestInputParamsResolver.php(80): MagentoWebapiControllerRestRequestValidator->validate()
  64. #19 C:wamp64wwwmg1vendormagentomodule-webapiControllerRest.php(299): MagentoWebapiControllerRestInputParamsResolver->resolve()
  65. #20 C:wamp64wwwmg1vendormagentomodule-webapiControllerRest.php(216): MagentoWebapiControllerRest->processApiRequest()
  66. #21 C:wamp64wwwmg1vargenerationMagentoWebapiControllerRestInterceptor.php(37): MagentoWebapiControllerRest->dispatch(Object(MagentoFrameworkAppRequestHttp))
  67. #22 C:wamp64wwwmg1vendormagentoframeworkAppHttp.php(135): MagentoWebapiControllerRestInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
  68. #23 C:wamp64wwwmg1vendormagentoframeworkAppBootstrap.php(258): MagentoFrameworkAppHttp->launch()
  69. #24 C:wamp64wwwmg1index.php(39): MagentoFrameworkAppBootstrap- >run(Object(MagentoFrameworkAppHttp))
  70. #25 {main}
  71.  
  72. $url = "http://127.0.0.1:8080/mg1/index.php/rest/V1/orders/1";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement