Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加使用media id发送图文消息的功能 #52

Merged
merged 1 commit into from
Jul 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Wechat/Message.php
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ class Message
const NEWS = 'news';
const TRANSFER = 'transfer';
const NEWS_ITEM = 'news_item';
const MP_NEWS = 'mp_news';

/**
* 创建消息实例
78 changes: 78 additions & 0 deletions src/Wechat/Messages/MpNews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Image.php
*
* Part of Overtrue\Wechat.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author overtrue <i@overtrue.me>
* @copyright 2015 overtrue <i@overtrue.me>
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace Overtrue\Wechat\Messages;

use Overtrue\Wechat\Media;

/**
* 多图文消息
*
* @property string $media_id
*/
class MpNews extends BaseMessage
{

/**
* 属性
*
* @var array
*/
protected $properties = array('media_id');

/**
* 设置Media_id
*
* @param string $mediaId
*
* @return Image
*/
public function media($mediaId)
{
$this->setAttribute('media_id', $mediaId);

return $this;
}

/**
* 生成主动消息数组
*
* @return array
*/
public function toStaff()
{
return array(
'mpnews' => array(
'media_id' => $this->media_id,
),
);
}

/**
* 生成回复消息数组
*
* @return array
*/
public function toReply()
{
throw new Exception(__CLASS__.'未实现此方法:toReply()');
/*return array(
'Image' => array(
'MediaId' => $this->media_id,
),
);
*/
}
}