发送音乐消息

@param string $toUser
@param string $title
@param string $description
@param string $musicurl
@param string $hqmusicurl
@param string $thumb_media_id
@return string
193660
public function sendMusic($toUser, $title, $description, $musicurl, $hqmusicurl, $thumb_media_id)
    {
        $hqmusicurl = $hqmusicurl == '' ? $musicurl : $hqmusicurl;
        $ret = array();
        $ret['touser'] = $toUser;
        $ret['msgtype'] = 'video';
        $ret['music']['title'] = $title;
        $ret['music']['description'] = $description;
        $ret['music']['musicurl'] = $musicurl;
        $ret['music']['hqmusicurl'] = $hqmusicurl;
        $ret['music']['thumb_media_id'] = $thumb_media_id;
        return $this->send($ret);
    }
91312
public function get_thumb_url($image_url, $orig_width, $orig_height, $thumb_width = 75, $force = false) {
        global $OUTPUT;

        if (!$force && $orig_width <= $thumb_width && $orig_height <= $thumb_width) {
            return $image_url;
        } else {
            $thumb_url = '';
            $commons_main_dir = 'https://upload.wikimedia.org/wikipedia/commons/';
            if ($image_url) {
                $short_path = str_replace($commons_main_dir, '', $image_url);
                $extension = strtolower(pathinfo($short_path, PATHINFO_EXTENSION));
                if (strcmp($extension, 'gif') == 0) {  //no thumb for gifs
                    return $OUTPUT->image_url(file_extension_icon('.gif', $thumb_width))->out(false);
                }
                $dir_parts = explode('/', $short_path);
                $file_name = end($dir_parts);
                if ($orig_height > $orig_width) {
                    $thumb_width = round($thumb_width * $orig_width/$orig_height);
                }
                $thumb_url = $commons_main_dir . 'thumb/' . implode('/', $dir_parts) . '/'. $thumb_width .'px-' . $file_name;
                if (strcmp($extension, 'svg') == 0) {  //png thumb for svg-s
                    $thumb_url .= '.png';
                }
            }
            return $thumb_url;
        }
    }
127188
function toMusicXML() {
        $out = '';
        $n   = 0;
        foreach ($this->notes as $note) {
            if (count($this->notes) > 1 && $n > 0) {
                $note->setProperty('chord', true);
            }

            $out .= $note->toMusicXML();
            $n++;
        }

        return $out;
    }
1092773
public function sendVideoByOpenid(array $toUsers, $media_id, $title = "", $description = "")
    {
        $ret = array();
        $ret['touser'] = $toUsers;
        $ret['msgtype'] = 'mpvideo';
        $ret['mpvideo']['media_id'] = $media_id;
        $ret['mpvideo']['title'] = $title;
        $ret['mpvideo']['description'] = $description;
        return $this->send($ret);
    }
664210
public function previewMpnews($media_id = '', $userid = '', $type = 'openid')
    {
        $queryStr = [];

        if ($type == 'towxname') {
            $queryStr['towxname'] = $userid;
        } else {
            $queryStr['touser'] = $userid;
        }

        $queryStr['mpnews']['media_id'] = $media_id;
        $queryStr['msgtype']            = 'mpnews';

        $this->module = 'message';

        $res = $this->_post('mass/preview', $queryStr);

        return $res;
    }
139835
function toMusicXML() {
		$out = '';

		$out .= '<note';
		if (isset($this->defaultX)) {
			$out .= ' default-x="'.$this->defaultX.'"';
		}

		if (isset($this->defaultY)) {
			$out .= ' default-y="'.$this->defaultY.'"';
		}

		$out .= '>';

		if (!empty($this->chord)) {
			$out .= '<chord/>';
		}

		if (!empty($this->cue)) {
			$out .= '<cue/>';
		}

		if (!empty($this->rest)) {
			$out .= '<rest/>';
		}

		if (!empty($this->pitch)) {
			if ($this->pitch instanceof Pitch) {
				$pitch = $this->pitch;
			} else {
				$pitch = Pitch::constructFromArray($this->pitch);
			}

			$out .= $pitch->toMusicXML();
		}

		if (!empty($this->duration)) {
			$out .= '<duration>'.$this->duration.'</duration>';
		}

		if (!empty($this->voice)) {
			$out .= '<voice>'.$this->voice.'</voice>';
		}

		if (!empty($this->type)) {
			$out .= '<type>'.$this->type.'</type>';
		}

		if (!empty($this->dot)) {
			$out .= '<dot/>';
		}

		if (!empty($this->tie)) {
			$out .= '<tie type="'.$this->tie.'"/>';
//            $this->notations['tie'] = $this->tie;
		}

		if (!empty($this->stem)) {
			$out .= $this->stem->toMusicXML();
		}

		if (!empty($this->staff)) {
			$out .= '<staff>'.$this->staff.'</staff>';
		}

		if (!empty($this->timeModification)) {
			if ($this->timeModification instanceof TimeModification) {
				$timeModification = $this->timeModification;
			} else {
				// we'll presume it's a string then
				$timeModification = TimeModification::constructFromArray($this->timeModification);
			}
			$out .= $timeModification->toMusicXML();
		}

		if (!empty($this->beams)) {
			if (!is_array($this->beams)) {
				$this->beams = array($this->beams);
			}
			foreach ($this->beams as $beam) {
				if (!($beam instanceof NoteBeam)) {
					// we'll presume it's a string then
					$beam = NoteBeam::constructFromArray($beam);
				}
			$out .= $beam->toMusicXML();
			}
		}

		if (!empty($this->stem)) {
			if ($this->stem instanceof NoteStem) {
				$stem = $this->stem;
			} else {
				$stem = NoteStem::constructFromArray($this->stem);
			}
			$out .= $stem->toMusicXML();
		}

		if (!empty($this->notations) || !empty($this->articulations)) {
			 $out .= '<notations>';

			foreach ($this->notations as $notation) {
				if (!($notation instanceof Notation)) {
					$notation = Notation::constructFromArray($notation);
				}

				$out .= $notation->toMusicXML();
			}

			if (!empty($this->articulations)) {
				$out .= '<articulations>';
				foreach ($this->articulations as $articulation) {
					if (!($articulation instanceof Articulation)) {
						$articulation = Articulation::constructFromArray($articulation);
					}
					$out .= $articulation->toMusicXML();
				}
				$out .= '</articulations>';
			}
			$out .= '</notations>';
		}

		$out .= '</note>';
		return $out;
	}
292806
public function replyMusic($title, $discription, $musicurl, $hqmusicurl, $thumb_media_id){
        return $this->response(func_get_args(), self::MSG_TYPE_MUSIC);
    }
1268571
public function send($touser, $template_id, $url, $data = [])
    {
        if (!is_string($touser) || !is_string($template_id) || !is_array($data) || empty($data)) {
            $this->setError('参数错误');

            return false;
        }

        $queryStr = [
            'touser'      => $touser,
            'template_id' => $template_id,
            'url'         => $url,
            'data'        => $data,
        ];

        $this->module = 'message';

        $res = $this->_post('template/send', $queryStr);

        return $res;
    }
1129472
private function thumb(string $title_pos, Post $post, int $count): string
    {
        if ($title_pos != $this->posts->args['title']['position']
            || !$this->posts->args['image']['size']
        ) {
            return '';
        }

        $attr = [];

        if ($this->posts->args['image']['margin']) {
            $attr['style'] = 'margin:'.\sanitize_text_field(
                \rtrim($this->posts->args['image']['margin']),
                ';'
            ).';';
        }

        return $post->thumbnail(
            $this->posts->args['image']['size'],
            $attr,
            $this->posts->args['image']['link']
        );
    }
217110
public function sendImageByOpenid(array $toUsers, $media_id, $title = "", $description = "")
    {
        $ret = array();
        $ret['touser'] = $toUsers;
        $ret['msgtype'] = 'image';
        $ret['image']['media_id'] = $media_id;
        $ret['image']['title'] = $title;
        $ret['image']['description'] = $description;
        return $this->send($ret);
    }
691207
public function getUrlTrackPageView($documentTitle = '')
    {
        $url = $this->getRequest($this->idSite);
        if (strlen($documentTitle) > 0) {
            $url .= '&action_name=' . urlencode($documentTitle);
        }

        return $url;
    }
807673
public function link ( SiteLink $toSiteLink, SiteLink $fromSiteLink, EditInfo $editInfo = null ) {
		$params = array(
			'tosite' => $toSiteLink->getSiteId(),
			'totitle' => $toSiteLink->getPageName(),
			'fromsite' => $fromSiteLink->getSiteId(),
			'fromtitle' => $fromSiteLink->getPageName(),
		);

		$this->api->postRequest( 'wblinktitles', $params, $editInfo );
		return true;
	}
1288143
function thumbTypeAudio() {
        $url = $this->getAttachUrl();
        return \HtmlAudio::setSrc($url . '?' . microtime(true))
                         ->setControls('controls');
    }
1190640
def _format_title_string(self, title_string):
        
        if "StreamTitle='" in title_string:
            tmp = title_string[title_string.find("StreamTitle='"):].replace("StreamTitle='", self.icy_title_prefix)
            ret_string = tmp[:tmp.find("';")]
        else:
            ret_string = title_string
        if '"artist":"' in ret_string:
            """ work on format:
                ICY Info: START_SONG='{"artist":"Clelia Cafiero","title":"M. Mussorgsky-Quadri di un'esposizione"}';
                Fund on "ClassicaViva Web Radio: Classical"
            """
            ret_string = self.icy_title_prefix + ret_string[ret_string.find('"artist":')+10:].replace('","title":"', ' - ').replace('"}\';', '')
        return self._title_string_format_text_tag(ret_string)
896873
function title( $contentObjectAttribute,  $name = "original_filename" )
    {
        $mediaFile = eZMedia::fetch( $contentObjectAttribute->attribute( "id" ),
                                      $contentObjectAttribute->attribute( "version" ) );

        if ( $mediaFile != null )
            $value = $mediaFile->attribute( $name );
        else
            $value = "";
        return $value;
    }
1223976
public function sendGraphTextByOpenid(array $toUsers, $media_id, $title = "", $description = "", $send_ignore_reprint = 1, $clientmsgid = '')
    {
        $ret = array();
        $ret['touser'] = $toUsers;
        $ret['msgtype'] = 'mpnews';
        $ret['mpnews']['media_id'] = $media_id;
        $ret['mpnews']['title'] = $title;
        $ret['mpnews']['description'] = $description;
        $ret['send_ignore_reprint'] = $send_ignore_reprint;
        $ret['clientmsgid'] = $clientmsgid;
        return $this->send($ret);
    }
976594
function title( $contentObjectAttribute, $name = "login" )
    {
        $user = $this->objectAttributeContent( $contentObjectAttribute );

        $value = $user->attribute( $name );

        return $value;
    }