Beispiel #1
0
function imglyUpload($image)
{
    $postdata = array('media' => "@{$image}", 'username' => getEncryptCookie('twitese_name'), 'password' => getEncryptCookie('twitese_pw'));
    $request = 'http://img.ly/api/upload';
    $result = objectifyXml(processCurl($request, $postdata));
    if (isset($result->mediaurl)) {
        return $result->mediaurl;
    } else {
        return false;
    }
}
Beispiel #2
0
function unshortUrl($text)
{
    $urlRegs = array();
    $urlRegs[] = '/http:\\/\\/bit\\.ly\\/([a-z0-9]{5}[a-z0-9]*)/i';
    $urlRegs[] = '/http:\\/\\/j\\.mp\\/([a-z0-9]{5}[a-z0-9]*)/i';
    $urlRegs[] = '/http:\\/\\/tinyurl\\.com\\/([a-z0-9]{5}[a-z0-9]*)/i';
    $urlRegs[] = '/http:\\/\\/retwt\\.me\\/([a-z0-9]{5}[a-z0-9]*)/i';
    $urlRegs[] = '/http:\\/\\/is\\.gd\\/([a-z0-9]{5}[a-z0-9]*)/i';
    /*根据需要开启
    		$urlRegs[] ='/http:\/\/moby\.to\/([a-z0-9]{5}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/tr\.im\/([a-z0-9]{4}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/snurl\.com\/([a-z0-9]{5}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/short\.ie\/([a-z0-9]{6}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/kl\.am\/([a-z0-9]{4}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/idek\.net\/([a-z0-9]{3}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/cli\.gs\/([a-z0-9]{6}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/u\.nu\/([a-z0-9]{5}[a-z0-9]*)/i';
    		$urlRegs[] ='/http:\/\/digg\.com\/([a-z0-9]{6}[a-z0-9]*)/i';
    		*/
    $objs = false;
    if (preg_match_all('/http:\\/\\/[a-z0-9\\/\\.]+[^<]/i', $text, $urls, PREG_PATTERN_ORDER)) {
        foreach ($urls[0] as $url) {
            foreach ($urlRegs as $urlReg) {
                if (preg_match_all($urlReg, $url, $matchs, PREG_PATTERN_ORDER)) {
                    foreach ($matchs[0] as $match) {
                        $request = 'http://api.unshort.me/?r=' . $match;
                        $obj = objectifyXml(processCurl($request));
                        if (isset($obj->resolvedURL) && trim($obj->resolvedURL) != '') {
                            $objs .= "<span>URL:<a href=\"{$obj->resolvedURL}\" target=\"_blank\">{$obj->resolvedURL}</a></span>";
                        }
                    }
                }
            }
        }
    }
    return $objs;
}