首页 > 作文

PHP实现发送微博消息功能完整示例

更新时间:2023-04-08 05:00:50 阅读: 评论:0

本文实例讲述了php实现发送微博消息功能。分享给大家供大家参考,具体如下:

<?php$cookie_file = dirname(__file__)."/weibo.cookie";$urname = '用户名';$password = '密码';  $urcenter = loginweibo($urname,$password);  echo ndmsg("不知道能不能成功呢!");  function ndmsg($msg){    global $cookie_file,$urcenter;    $posturl = "/d/file/titlepic/visitor    $postdata['text'] = $msg;    $postdata['pic_id'] = "";    $postdata['rank'] = 0;    $postdata['rankid'] = "";    $postdata['_surl'] = "";艾叶的作用    $postdata['hottopicid'] = "";    $postdata['location'] = "home";    $postdata['module'] = "stissue";    $postdata['_t'] = 0;    foreach($postdata as $key =>$value){        $tmp .= $key."=".$value."&";    }    $post = trim($tmp,"&");    $header = array(      'host:weibo.com',      'accept: */*',      'accep大学毕业典礼t-language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3',      'content-type:application/x-www-form-urlencoded',      'x-requested-with:xmlhttprequest',      'referer: '.$urcenter,    );    //var_dump($header);exit;    $ch = curl_init();    curl_topt($ch,curlopt_url,$posturl);    curl_topt($ch,curlopt_returntransfer,1);    curl_topt($ch,curlopt_cookiefile, $cookie_file);    curl_topt($ch,curlopt_uragent,'mozilla/5.0 (windows nt 6.1; wow64; rv:30.0) gecko/20100101 firefox/30.0');    curl_topt($ch,curlopt_httpheader,$header);    curl_topt($ch,curlopt_post,1);    curl_topt($ch,curlopt_postfields,$post);    $str = curl_exec($ch);    curl_clo($ch);    return $str;  }  function loginweibo($u,$p){    global $cookie_file ;    //$password = sha1(sha1(sha1($p)).$encryption['rvertime'].$encryption['nonce']);    $password = $p;    $urname = ba64_encode($u);    $loginurl = 'https://login.sina.com.cn/台湾特色小吃sso/login.php?client=ssologin.js(v1.4.15)&_=1403138799543';    $logindata['entry'] = 'sso';    $logindata['gateway'] = '1';    $logindata['from'] = 'null';    $logindata['savestate'] = '30';    $logindata['uticket'] = '0';    $logindata['pagerefer'] = '';    $logindata['vsnf'] = '1';    $logindata['su'] = ba64_encode($u);    $logindata['rvice'] = 'sso';    $logindata['sp'] = $password;    $logindata['sr'] = '1920*1080';    $logindata['encoding'] = 'utf-8';    $logindata['cdult'] = '3';    $logindata['domain'] = 'sina.com.cn';    $logindata['prelt'] = '0';    $logindata['returntype'] = 'text';    //var_dump七一党员大会议程($logindata);exit;    $login = json_decode(loginpost($loginurl,$logindata),true);    //获取微博    get($login['crossdomainurllist'][0]);    $ch = curl_init();    curl_topt($ch,curlopt_url,"http://weibo.com");      curl_topt($ch,curlopt_returntransfer,1);      curl_topt($ch,curlopt_cookiefile, $cookie_file);      curl_topt($ch,curlopt_cookiejar,$cookie_file);      $return = curl_exec($ch);    $info = curl_getinfo($ch);    吉珠大学curl_clo($ch);    $ch = curl_init();    curl_topt($ch,curlopt_url,$info['redirect_url']);      curl_topt($ch,curlopt_returntransfer,1);      curl_topt($ch,curlopt_cookiefile, $cookie_file);      curl_topt($ch,curlopt_cookiejar,$cookie_file);      curl_exec($ch);    curl_clo($ch);    return $info['redirect_url'];  }  function loginpost($url,$data){    global $cookie_file ;    //echo $cookie_file ;exit;    $tmp = '';    if(is_array($data)){        foreach($data as $key =>$value){            $tmp .= $key."=".$value."&";        }        $post = trim($tmp,"&");    }el{        $post = $data;    }    $ch = curl_init();    curl_topt($ch,curlopt_url,$url);      curl_topt($ch,curlopt_returntransfer,1);      curl_topt($ch, curlopt_ssl_verifypeer, fal);    curl_topt($ch, curlopt_ssl_verifyhost, fal);        curl_topt($ch,curlopt_post,1);    curl_topt($ch,curlopt_postfields,$post);    curl_topt($ch,curlopt_cookiejar,$cookie_file);    curl_topt($ch,curlopt_cookiejar,$cookie_file);    $return = curl_exec($ch);    $info = curl_getinfo($ch);    curl_clo($ch);    return $return;  }  function post($url,$data){    global $cookie_file;    $tmp = '';    if(is_array($data)){        foreach($data as $key =>$value){            $tmp .= $key."=".$value."&";        }        $post = trim($tmp,"&");    }el{        $post = $data;    }    $ch = curl_init();    curl_topt($ch,curlopt_url,$url);      curl_topt($ch,curlopt_returntransfer,1);          curl_topt($ch,curlopt_post,1);    curl_topt($ch,curlopt_cookiefile, $cookie_file);    curl_topt($ch,curlopt_postfields,$post);    $return = curl_exec($ch);    $info = curl_getinfo($ch);    curl_clo($ch);    return $return;  }  function get($url,$getinfo=fal){      global $cookie_file;        $ch = curl_init();      curl_topt($ch,curlopt_url,$url);        curl_topt($ch,curlopt_returntransfer,1);        curl_topt($ch,curlopt_cookiefile, $cookie_file);        curl_topt($ch,curlopt_cookiejar,$cookie_file);        curl_topt($ch, curlopt_ssl_verifypeer, fal);      curl_topt($ch, curlopt_ssl_verifyhost, fal);            $return = curl_exec($ch);      $info = curl_getinfo($ch);      if($getinfo)return $info;      curl_clo($ch);      return $return;  }  function mp(){    $getrndcode = "/d/file/titlepic/prelogin.php    @preg_match_all('/\((.*?)\)/is',get($getrndcode,$data),$data);    $encryption = json_decode($data[1][0],true);    return $encryption;  }

本文发布于:2023-04-08 05:00:48,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/65268a60f3ac9c67dff2ea9c82fdb35f.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:PHP实现发送微博消息功能完整示例.doc

本文 PDF 下载地址:PHP实现发送微博消息功能完整示例.pdf

标签:议程   给大家   台湾   大学毕业
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图