Skip to content

Commit

Permalink
The company publishes content to the customer circle of friends , Upl…
Browse files Browse the repository at this point in the history
…oad attached resource (#2688)

* The company publishes content to the customer circle of friends , Upload attached resource

* 改成驼峰命名

* 修正格式
  • Loading branch information
DivinerSheep authored Apr 28, 2023
1 parent 4accb06 commit 92791f5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Work/ExternalContact/MessageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,19 @@ protected function formatFields(array $data = [], array $default = [])

return $params;
}

/**
* 企业发表内容到客户的朋友圈
*
* @see https://developer.work.weixin.qq.com/document/path/95094
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function moments(array $msg)
{
return $this->httpPostJson('cgi-bin/externalcontact/add_moment_task', $msg);
}
}
32 changes: 32 additions & 0 deletions src/Work/Media/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ public function uploadFile(string $path)
return $this->upload('file', $path);
}

/**
* Upload Attachment Resources
*
* @return mixed
*/
public function uploadAttachmentResources(string $path, string $mediaType = 'image', int $attachmentType = 1)
{
return $this->uploadAttachment($path, $mediaType, $attachmentType);
}

/**
* Upload media.
*
Expand All @@ -100,4 +110,26 @@ public function upload(string $type, string $path)

return $this->httpUpload('cgi-bin/media/upload', $files, [], compact('type'));
}

/**
* Upload media
*
* @return mixed
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function uploadAttachment(string $path, string $mediaType, int $attachmentType)
{
$files = [
'media' => $path,
];

$query = [
'media_type' => $mediaType,
'attachment_type' => $attachmentType,
];

return $this->httpUpload('cgi-bin/media/upload_attachment', $files, [], $query);
}
}

0 comments on commit 92791f5

Please sign in to comment.