Zeka Posted August 18, 2018 Share Posted August 18, 2018 I'm planning to start a project where remote API will be involved and thinking about tools to work with API. Of course, we have WireHttp class and actually, I think to go with it, but maybe there are more specialized alternatives that worth to consider? Link to comment Share on other sites More sharing options...
adrian Posted August 19, 2018 Share Posted August 19, 2018 I tend to use wireHttp. Here's a recent example: https://github.com/adrianbj/CookieManagementBanner/blob/a8e66127bdcbd80e10ac797ad5cbb143644c7857/CookieManagementBanner.module#L38-L39 $http = new WireHttp(); $userLocation = $http->getJSON('https://extreme-ip-lookup.com/json/'.$this->get_user_ip_addr()); 7 Link to comment Share on other sites More sharing options...
Guy Verville Posted August 19, 2018 Share Posted August 19, 2018 I use WireHttp too. Quite convenient. I use it to make two ProcessWire talk to each other. Link to comment Share on other sites More sharing options...
adrian Posted August 19, 2018 Share Posted August 19, 2018 26 minutes ago, Guy Verville said: I use it to make two ProcessWire talk to each other. Just in case you don't know, you can do this directly via the API: https://processwire.com/blog/posts/multi-instance-pw3/ Link to comment Share on other sites More sharing options...
Guy Verville Posted August 19, 2018 Share Posted August 19, 2018 Thank you. It is interesting. As we don't know if we will host the two sites, it can be tricky to get there. But I will give it a try! 1 Link to comment Share on other sites More sharing options...
adrian Posted August 19, 2018 Share Posted August 19, 2018 3 hours ago, Guy Verville said: Thank you. It is interesting. As we don't know if we will host the two sites, it can be tricky to get there. But I will give it a try! Of course - that is a good reason to not use it. It was on Ryan's roadmap to allow it to work over http, but not sure when/if that will happen. 1 Link to comment Share on other sites More sharing options...
Zeka Posted August 19, 2018 Author Share Posted August 19, 2018 @adrian, @Guy Verville Thanks for your inputs. I tested WireHttp a little today and I must say that it's quite convenient, so I will use it. The beauty of PW, one tool for almost all tasks. $clantag = "test"; $token = "---"; $url = "https://site.com/" . urlencode($clantag); $http = new WireHttp(); $http->setValidateURLOptions([ 'convertEncoded' => false, 'encodeSpace' => true ]); $http->setHeaders([ 'Accept' => "application/json", 'Authorization' => "Bearer " . $token ]); $response = $http->getJSON($url); d($response); 5 Link to comment Share on other sites More sharing options...
Recommended Posts