Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
j'ai etendu la classe Zend_Service_Twitter de manière à ajouter la methode statusUpdateWithMedia.
Cette methode n'est pas implémenté nativement et j'en ai besoin pour associer une image à mon tweet.
J'ai donc repris la methode statusUpdate et je l'ai un peu customiser de cette manière:
en rouge, ce que j'ai rajouter /modifier par rapport à la methode statusUpdate
public function statusUpdateWithMedia($status, $image, $inReplyToStatusId = null) { $this->_init(); $path = '1/statuses/update_with_media.xml'; $len = iconv_strlen(htmlspecialchars($status, ENT_QUOTES, 'UTF-8'), 'UTF-8'); if ($len > self::STATUS_MAX_CHARACTERS) { include_once 'Zend/Service/Twitter/Exception.php'; throw new Zend_Service_Twitter_Exception( 'Status must be no more than ' . self::STATUS_MAX_CHARACTERS . ' characters in length' ); } elseif (0 == $len) { include_once 'Zend/Service/Twitter/Exception.php'; throw new Zend_Service_Twitter_Exception( 'Status must contain at least one character' ); } $data = array('status' => $status, 'media[]' => "@{$image}"; if (is_numeric($inReplyToStatusId) && !empty($inReplyToStatusId)) { $data['in_reply_to_status_id'] = $inReplyToStatusId; } $response = $this->_post($path, $data); return new Zend_Rest_Client_Result($response->getBody()); }
public function statusUpdateWithMedia($status, $image, $inReplyToStatusId = null)
{
$this->_init();
$path = '1/statuses/update_with_media.xml';
$len = iconv_strlen(htmlspecialchars($status, ENT_QUOTES, 'UTF-8'), 'UTF-8');
if ($len > self::STATUS_MAX_CHARACTERS) {
include_once 'Zend/Service/Twitter/Exception.php';
throw new Zend_Service_Twitter_Exception(
'Status must be no more than '
. self::STATUS_MAX_CHARACTERS
. ' characters in length'
);
} elseif (0 == $len) {
include_once 'Zend/Service/Twitter/Exception.php';
throw new Zend_Service_Twitter_Exception(
'Status must contain at least one character'
);
}
$data = array('status' => $status,
'media[]' => "@{$image}");
if (is_numeric($inReplyToStatusId) && !empty($inReplyToStatusId)) {
$data['in_reply_to_status_id'] = $inReplyToStatusId;
}
$response = $this->_post($path, $data);
return new Zend_Rest_Client_Result($response->getBody());
}
seulement ca fonctionne pas biensur.
quelqu'un l'a déjà peut être fait ?
Merci de votre aide.
Dernière modification par Myfred (04-10-2011 17:00:44)
Hors ligne