This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
找不到postJson()这个方法 #98
Comments
你是laravel8吗? 你是如何解决这个问题的? |
好的, 谢啦 |
App\Common\Dingtalk\Http\Client.php<?php
namespace App\Common\Dingtalk\Http;
use EasyDingTalk\Kernel\Http\Client as BaseClient;
class Client extends BaseClient {
public function version()
{
return ['http_client_version' => 'hello world 1.0'];
}
/**
* GET request.
*
* @param string $url
* @param array $query
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return \Psr\Http\Message\ResponseInterface|\Overtrue\Http\Support\Collection|array|object|string
*/
public function get(string $url, array $query = [], $async = false)
{
return $this->request($url, 'GET', ['query' => $query], $async);
}
/**
* JSON request.
*
* @param string $url
* @param string|array $data
* @param array $query
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return \Psr\Http\Message\ResponseInterface|\Overtrue\Http\Support\Collection|array|object|string
*/
public function postJson(string $url, array $data = [], array $query = [])
{
return $this->request($url, 'POST', ['query' => $query, 'json' => $data]);
}
} App\Common\Dingtalk\Http\ServiceProvider.phpnamespace App\Common\Dingtalk\Http;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
class ServiceProvider implements ServiceProviderInterface
{
/**
* Registers services on the given container.
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param \Pimple\Container $pimple A container instance
*/
public function register(Container $pimple)
{
// isset($pimple['client']) ||
$pimple['client'] = function ($app) {
return new Client($app);
};
}
} 找到了比较合适的解决方案了,这样就不用hard code进vendor了 |
👍👍👍 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Call to undefined method EasyDingTalk\Kernel\Http\Client::postJson()
The text was updated successfully, but these errors were encountered: