Skip to content

Instantly share code, notes, and snippets.

@lbj96347
Created July 4, 2012 05:24
Show Gist options
  • Select an option

  • Save lbj96347/3045537 to your computer and use it in GitHub Desktop.

Select an option

Save lbj96347/3045537 to your computer and use it in GitHub Desktop.
tencent weibo pic & t share
<?php
//腾讯微博,分享微博加图片
if($url){
//$ext=substr($url, -3,3);
$ext=strrchr($url,".");
//查找'.'字符串出现的位置
$filename=date("YMDHis").$ext;
//定义文件名字为日期+网址
$exName = strtolower(substr($filename,(strrpos($filename,'.')+1)));
//文件名字,去掉文件格式
ob_start();
//ob_start这个到底是开了线程去获取文件
readfile($url);
$img = ob_get_contents();
//获取二进制数据
ob_end_clean();
//发送到腾讯微博的api上面
$p =array(
'c' => $weibo.'♫'.$url_this.'/play/'.$rsid.'/ #点歌台#',
'ip' => $_SERVER['REMOTE_ADDR'],
'j' => '',
'w' => '',
'p' => array('image/'.$exName,$filename,$img),
//发送图片的接口
'type' => 0
);
}
else {
$p =array(
'c' => $weibo.'♫'.$url_this.'/play/'.$rsid.'/ #点歌台#',
'ip' => $_SERVER['REMOTE_ADDR'],
'j' => '',
'w' => '',
'p' => '',
'type' => 0
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment