Skip to content

Commit

Permalink
百度推送问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xutl committed Mar 29, 2021
1 parent 4e8f457 commit 83ac4ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Jobs/DeleteJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public function __construct(BaiduPush $baiduPush)
public function handle()
{
try {
Http::contentType('text/plain')->post("http://data.zz.baidu.com/del?site={$this->site}&token={$this->token}", [
'body' => $this->baiduPush->url
]);
Http::acceptJson()
->withBody($this->baiduPush->url, 'text/plain')
->post("http://data.zz.baidu.com/del?site={$this->site}&token={$this->token}");
} catch (\Exception $e) {
Log::error($e->getMessage());
}
Expand Down
12 changes: 6 additions & 6 deletions src/Jobs/PushJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ public function handle()
{
try {
if ($this->baiduPush->type == BaiduPush::TYPE_SITE) {
$response = Http::contentType('text/plain')->post("http://data.zz.baidu.com/urls?site={$this->site}&token={$this->token}", [
'body' => $this->baiduPush->url
]);
$response = Http::acceptJson()
->withBody($this->baiduPush->url, 'text/plain')
->post("http://data.zz.baidu.com/urls?site={$this->site}&token={$this->token}");
if (isset($response['error'])) {
$this->baiduPush->setFailure($response['error'] . ':' . $response['message']);
} else {
$this->baiduPush->setSuccess();
}
} else if ($this->baiduPush->type == BaiduPush::TYPE_DAILY) {
$response = Http::contentType('text/plain')->post("http://data.zz.baidu.com/urls?site={$this->site}&token={$this->token}&type=daily", [
'body' => $this->baiduPush->url
]);
$response = Http::acceptJson()
->withBody($this->baiduPush->url, 'text/plain')
->post("http://data.zz.baidu.com/urls?site={$this->site}&token={$this->token}&type=daily");
if (isset($response['error'])) {
$this->baiduPush->setFailure($response['error'] . ':' . $response['message']);
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/Jobs/UpdateJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ public function __construct(BaiduPush $baiduPush)
public function handle()
{
try {
$response = Http::contentType('text/plain')->post("http://data.zz.baidu.com/update?site={$this->site}&token={$this->token}", [
'body' => $this->baiduPush->url
]);

$response = Http::acceptJson()
->withBody($this->baiduPush->url, 'text/plain')
->post("http://data.zz.baidu.com/update?site={$this->site}&token={$this->token}");
if (isset($response['error'])) {
$this->baiduPush->setFailure($response['error'] . ':' . $response['message']);
} else {
Expand Down

0 comments on commit 83ac4ca

Please sign in to comment.