新浪微博、腾讯微博、QQ、人人网、开心网、网易微博、豆瓣、百度、Google、微软、Instagram、Facebook、360、GitHub等平台的账号登录及api操作,使用oauth 2.0
官方提供的sdk都太过庞大,这是我自己简化的,提供简单的账号登录、获取个人信息、发布微博等功能,如果需要其他功能可以根据官方的api文档自行添加
2012-12-30:增加示例文件
2012-12-31:增加Facebook
2013-04-02:更新QQ、人人网、开心网、豆瓣、百度、Google、微软、Facebook
2013-05-09:增加GitHub
代码已提交到GIt @ OSC:http://git.oschina.net/piscdong/sns_php,这里将不再更新
<?php /** * PHP Library for weibo.com * * @author PiscDong (http://www.piscdong.com/) */ class sinaPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url ); return 'https://api.weibo.com/oauth2/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://api.weibo.com/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } /** function access_token_refresh($refresh_token){ } **/ function get_uid(){ $params=array(); $url='https://api.weibo.com/2/account/get_uid.json'; return $this->api($url, $params); } function show_user_by_id($uid){ $params=array( 'uid'=>$uid ); $url='https://api.weibo.com/2/users/show.json'; return $this->api($url, $params); } function statuses_count($ids){ $params=array( 'ids'=>$ids ); $url='https://api.weibo.com/2/statuses/count.json'; return $this->api($url, $params); } function get_comments_by_sid($id, $count=10, $page=1){ $params=array( 'id'=>$id, 'page'=>$page, 'count'=>$count ); $url='https://api.weibo.com/2/comments/show.json'; return $this->api($url, $params); } function repost_timeline($id, $count=10, $page=1){ $params=array( 'id'=>$id, 'page'=>$page, 'count'=>$count ); $url='https://api.weibo.com/2/statuses/repost_timeline.json'; return $this->api($url, $params); } function update($img_c, $pic=''){ $params=array( 'status'=>$img_c ); if($pic!='' && is_array($pic)){ $url='https://api.weibo.com/2/statuses/upload.json'; $params['pic']=$pic; }else{ $url='https://api.weibo.com/2/statuses/update.json'; } return $this->api($url, $params, 'POST'); } function user_timeline($uid, $count=10, $page=1){ $params=array( 'uid'=>$uid, 'page'=>$page, 'count'=>$count ); $url='https://api.weibo.com/2/statuses/user_timeline.json'; return $this->api($url, $params); } function querymid($id, $type=1, $is_batch=0){ $params=array( 'id'=>$id, 'type'=>$type, 'is_batch'=>$is_batch ); $url='https://api.weibo.com/2/statuses/querymid.json'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ if(isset($params['pic'])){ uksort($params, 'strcmp'); $str_b=uniqid('------------------'); $str_m='--'.$str_b; $str_e=$str_m. '--'; $body=''; foreach($params as $k=>$v){ if($k=='pic'){ if(is_array($v)){ $img_c=$v[2]; $img_n=$v[1]; }elseif($v{0}=='@'){ $url=ltrim($v, '@'); $img_c=file_get_contents($url); $url_a=explode('?', basename($url)); $img_n=$url_a[0]; } $body.=$str_m."\r\n"; $body.='Content-Disposition: form-data; name="'.$k.'"; filename="'.$img_n.'"'."\r\n"; $body.="Content-Type: image/unknown\r\n\r\n"; $body.=$img_c."\r\n"; }else{ $body.=$str_m."\r\n"; $body.='Content-Disposition: form-data; name="'.$k."\"\r\n\r\n"; $body.=$v."\r\n"; } } $body.=$str_e; $headers[]="Content-Type: multipart/form-data; boundary=".$str_b; $result=$this->http($url, $body, 'POST', $headers); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: sinaPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
2. [文件] 腾讯微博 ~ 5KB
<?php /** * PHP Library for t.qq.com * * @author PiscDong (http://www.piscdong.com/) */ class tqqPHP { function __construct($client_id, $client_secret, $access_token=NULL, $openid=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; $this->openid=$openid; } function login_url($callback_url){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url ); return 'https://open.t.qq.com/cgi-bin/oauth2/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://open.t.qq.com/cgi-bin/oauth2/access_token?'.http_build_query($params); $result_str=$this->http($url); $json_r=array(); if($result_str!='')parse_str($result_str, $json_r); return $json_r; } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id ); $url='https://open.t.qq.com/cgi-bin/oauth2/access_token?'.http_build_query($params); $result_str=$this->http($url); $json_r=array(); if($result_str!='')parse_str($result_str, $json_r); return $json_r; } function me(){ $params=array(); $url='https://open.t.qq.com/api/user/info'; return $this->api($url, $params); } function getgetMyTweet($reqnum=10, $pageflag=0){ $params=array( 'pageflag'=>$pageflag, 'reqnum'=>$reqnum ); $url='https://open.t.qq.com/api/statuses/broadcast_timeline'; return $this->api($url, $params); } function getRecount($ids){ $params=array( 'ids'=>$ids, 'flag'=>2 ); $url='https://open.t.qq.com/api/t/re_count'; return $this->api($url, $params); } function getReplay($id, $flag=0, $f=0, $n=10){ $params=array( 'rootid'=>$id, 'pageflag'=>$f, 'reqnum'=>$n, 'flag'=>$flag ); $url='https://open.t.qq.com/api/t/re_list'; return $this->api($url, $params); } function postOne($img_c, $pic=''){ $params=array( 'content'=>$img_c ); if($pic!='' && is_array($pic)){ $url='https://open.t.qq.com/api/t/add_pic'; $params['pic']=$pic; }else{ $url='https://open.t.qq.com/api/t/add'; } return $this->api($url, $params, 'POST'); } function api($url, $params, $method='GET'){ $params['oauth_consumer_key']=$this->client_id; $params['access_token']=$this->access_token; $params['openid']=$this->openid; $params['clientip']=$this->getIP(); $params['oauth_version']='2.a'; $params['format']='json'; $params['scope']='all'; if($method=='GET'){ $result_str=$this->http($url.'?'.http_build_query($params)); }else{ if(isset($params['pic'])){ uksort($params, 'strcmp'); $str_b=uniqid('------------------'); $str_m='--'.$str_b; $str_e=$str_m. '--'; $body=''; foreach($params as $k=>$v){ if($k=='pic'){ if(is_array($v)){ $img_c=$v[2]; $img_n=$v[1]; }elseif($v{0}=='@'){ $url=ltrim($v, '@'); $img_c=file_get_contents($url); $url_a=explode('?', basename($url)); $img_n=$url_a[0]; } $body.=$str_m."\r\n"; $body.='Content-Disposition: form-data; name="'.$k.'"; filename="'.$img_n.'"'."\r\n"; $body.="Content-Type: image/unknown\r\n\r\n"; $body.=$img_c."\r\n"; }else{ $body.=$str_m."\r\n"; $body.='Content-Disposition: form-data; name="'.$k."\"\r\n\r\n"; $body.=$v."\r\n"; } } $body.=$str_e; $headers[]="Content-Type: multipart/form-data; boundary=".$str_b; $result_str=$this->http($url, $body, 'POST', $headers); }else{ $result_str=$this->http($url, http_build_query($params), 'POST'); } } $json_r=array(); if($result_str!='')$json_r=json_decode($result_str, true); return $json_r; } function getIP(){ if(isset($_ENV['HTTP_CLIENT_IP'])){ $ip=$_ENV['HTTP_CLIENT_IP']; }elseif(isset($_ENV['HTTP_X_FORWARDED_FOR'])){ $ip=$_ENV['HTTP_X_FORWARDED_FOR']; }elseif(isset($_ENV['REMOTE_ADDR'])){ $ip=$_ENV['REMOTE_ADDR']; }else{ $ip=$_SERVER['REMOTE_ADDR']; } if(strstr($ip, ':')){ $ipa=explode(':', $ip); foreach($ipa as $v){ if(strlen($v)>7)$ip=$v; } } if(strlen($ip)<7)$ip='0.0.0.0'; return $ip; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: tqqPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); return $response; } }
3. [文件] QQ ~ 3KB
<?php /** * PHP Library for qq.com * * @author PiscDong (http://www.piscdong.com/) */ class qqPHP { function __construct($appid, $appkey, $access_token=NULL){ $this->appid=$appid; $this->appkey=$appkey; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'client_id'=>$this->appid, 'redirect_uri'=>$callback_url, 'response_type'=>'code', 'scope'=>$scope ); return 'https://graph.qq.com/oauth2.0/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'client_id'=>$this->appid, 'client_secret'=>$this->appkey, 'code'=>$code, 'state'=>'', 'redirect_uri'=>$callback_url ); $url='https://graph.qq.com/oauth2.0/token?'.http_build_query($params); $result_str=$this->http($url); $json_r=array(); if($result_str!='')parse_str($result_str, $json_r); return $json_r; } /** function access_token_refresh($refresh_token){ } **/ function get_openid(){ $params=array( 'access_token'=>$this->access_token ); $url='https://graph.qq.com/oauth2.0/me?'.http_build_query($params); $result_str=$this->http($url); $json_r=array(); if($result_str!=''){ preg_match('/callback\(\s+(.*?)\s+\)/i', $result_str, $result_a); $json_r=json_decode($result_a[1], true); } return $json_r; } function get_user_info($openid){ $params=array( 'openid'=>$openid ); $url='https://graph.qq.com/user/get_user_info'; return $this->api($url, $params); } function add_share($openid, $title, $url, $site, $fromurl, $images='', $summary=''){ $params=array( 'openid'=>$openid, 'title'=>$title, 'url'=>$url, 'site'=>$site, 'fromurl'=>$fromurl, 'images'=>$images, 'summary'=>$summary ); $url='https://graph.qq.com/share/add_share'; return $this->api($url, $params, 'POST'); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; $params['oauth_consumer_key']=$this->appid; $params['format']='json'; if($method=='GET'){ $result_str=$this->http($url.'?'.http_build_query($params)); }else{ $result_str=$this->http($url, http_build_query($params), 'POST'); } $result=array(); if($result_str!='')$result=json_decode($result_str, true); return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: qqPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); return $response; } }
4. [文件] 人人网 ~ 3KB
<?php /** * PHP Library for renren.com * * @author PiscDong (http://www.piscdong.com/) */ class renrenPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope ); return 'https://graph.renren.com/oauth/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://graph.renren.com/oauth/token'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret ); $url='https://graph.renren.com/oauth/token'; return $this->http($url, http_build_query($params), 'POST'); } function me(){ $params=array(); return $this->api('users.getInfo', $params, 'POST'); } function setStatus($status){ $params=array( 'status'=>$status ); return $this->api('status.set', $params, 'POST'); } function getStatus($uid, $count=10, $page=1){ $params=array( 'uid'=>$uid, 'page'=>$page, 'count'=>$count ); return $this->api('status.gets', $params, 'POST'); } function addBlog($title, $content){ $params=array( 'title'=>$title, 'content'=>$content ); return $this->api('blog.addBlog', $params, 'POST'); } function getBlog($id, $uid){ $params=array( 'id'=>$id, 'uid'=>$uid ); return $this->api('blog.get', $params, 'POST'); } function getComments($id, $uid, $count=10, $page=1){ $params=array( 'id'=>$id, 'uid'=>$uid, 'page'=>$page, 'count'=>$count ); return $this->api('blog.getComments', $params, 'POST'); } function api($method_name, $params, $method='GET'){ $params['method']=$method_name; $params['v']='1.0'; $params['access_token']=$this->access_token; $params['format']='json'; ksort($params); $sig_str=''; foreach($params as $k=>$v)$sig_str.=$k.'='.$v; $sig_str.=$this->client_secret; $sig=md5($sig_str); $params['sig']=$sig; $url='http://api.renren.com/restserver.do'; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: renrenPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
5. [文件] 开心网 ~ 3KB
<?php /** * PHP Library for kaixin001.com * * @author PiscDong (http://www.piscdong.com/) */ class kaixinPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope ); return 'http://api.kaixin001.com/oauth2/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://api.kaixin001.com/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret ); $url='https://api.kaixin001.com/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } function me(){ $params=array(); $url='https://api.kaixin001.com/users/me.json'; return $this->api($url, $params); } function records_add($content, $picurl=''){ $params=array( 'content'=>$content ); if($picurl!='')$params['picurl']=$picurl; $url='https://api.kaixin001.com/records/add.json'; return $this->api($url, $params, 'POST'); } function records_me($num=10, $start=0){ $params=array( 'start'=>$start, 'num'=>$num ); $url='https://api.kaixin001.com/records/me.json'; return $this->api($url, $params); } function comment_list($id, $uid, $num=10, $start=0){ $params=array( 'objtype'=>'records', 'objid'=>$id, 'ouid'=>$uid, 'start'=>$start, 'num'=>$num ); $url='https://api.kaixin001.com/comment/list.json'; return $this->api($url, $params); } function forward_list($id, $uid, $num=10, $start=0){ $params=array( 'objtype'=>'records', 'objid'=>$id, 'ouid'=>$uid, 'start'=>$start, 'num'=>$num ); $url='https://api.kaixin001.com/forward/list.json'; return $this->api($url, $params); } function like_show($id, $uid, $num=10, $start=0){ $params=array( 'objtype'=>'records', 'objid'=>$id, 'ouid'=>$uid, 'start'=>$start, 'num'=>$num ); $url='https://api.kaixin001.com/like/show.json'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: kaixinPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
6. [文件] 网易微博 ~ 3KB
<?php /** * PHP Library for t.163.com * * @author PiscDong (http://www.piscdong.com/) */ class t163PHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url ); return 'https://api.t.163.com/oauth2/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://api.t.163.com/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret ); $url='https://api.t.163.com/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } function me(){ $params=array(); $url='https://api.t.163.com/users/show.json'; return $this->api($url, $params); } function user_timeline($id, $count=10){ $params=array( 'user_id'=>$id, 'count'=>$count ); $url='https://api.t.163.com/statuses/user_timeline.json'; return $this->api($url, $params); } function update($status){ $params=array( 'status'=>$status ); $url='https://api.t.163.com/statuses/update.json'; return $this->api($url, $params, 'POST'); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: t163PHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
7. [文件] 豆瓣 ~ 3KB
<?php /** * PHP Library for douban.com * * @author PiscDong (http://www.piscdong.com/) */ class doubanPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope, 'state'=>md5(time()) ); return 'https://www.douban.com/service/auth2/auth?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://www.douban.com/service/auth2/token'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($callback_url, $refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://www.douban.com/service/auth2/token'; return $this->http($url, http_build_query($params), 'POST'); } function me(){ $params=array(); $url='https://api.douban.com/v2/user/~me'; return $this->api($url, $params); } function share($text, $title, $url, $description='', $pic=''){ $params=array( 'text'=>$text, 'rec_title'=>$title, 'rec_url'=>$url, 'rec_desc'=>$description, 'rec_image'=>$pic ); $url='https://api.douban.com/shuo/v2/statuses/'; return $this->api($url, $params, 'POST'); } function api($url, $params, $method='GET'){ $headers[]="Authorization: Bearer ".$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params), '', 'GET', $headers); }else{ $result=$this->http($url, http_build_query($params), 'POST', $headers); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: doubanPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
8. [文件] 百度 ~ 2KB
<?php /** * PHP Library for baidu.com * * @author PiscDong (http://www.piscdong.com/) */ class baiduPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope, 'state'=>md5(time()), 'display'=>'page' ); return 'https://openapi.baidu.com/oauth/2.0/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://openapi.baidu.com/oauth/2.0/token'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret ); $url='https://openapi.baidu.com/oauth/2.0/token'; return $this->http($url, http_build_query($params), 'POST'); } function user(){ $params=array(); $url='https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: baiduPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
9. [文件] Google ~ 2KB
<?php /** * PHP Library for google.com * * @author PiscDong (http://www.piscdong.com/) */ class googlePHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope, 'state'=>'profile', 'access_type'=>'offline' ); return 'https://accounts.google.com/o/oauth2/auth?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://accounts.google.com/o/oauth2/token'; $result=$this->http($url, http_build_query($params), 'POST'); return $result; } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret ); $url='https://accounts.google.com/o/oauth2/token'; $result=$this->http($url, http_build_query($params), 'POST'); return $result; } function me(){ $params=array(); $url='https://www.googleapis.com/oauth2/v1/userinfo'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $headers[]="Authorization: Bearer ".$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params), '', 'GET', $headers); }else{ $result=$this->http($url, http_build_query($params), 'POST', $headers); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: google(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
10. [文件] 微软 ~ 2KB
<?php /** * PHP Library for live.com * * @author PiscDong (http://www.piscdong.com/) */ class livePHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope ); return 'https://login.live.com/oauth20_authorize.srf?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://login.live.com/oauth20_token.srf'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_secret'=>$this->client_secret, 'client_id'=>$this->client_id ); $url='https://login.live.com/oauth20_token.srf'; return $this->http($url, http_build_query($params), 'POST'); } function me(){ $params=array(); $url='https://apis.live.net/v5.0/me'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: livePHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
11. [文件] Instagram ~ 2KB
<?php /** * PHP Library for instagram.com * * @author PiscDong (http://www.piscdong.com/) */ class instagramPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url ); return 'https://api.instagram.com/oauth/authorize/?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://api.instagram.com/oauth/access_token'; return $this->http($url, http_build_query($params), 'POST'); } /** function access_token_refresh($refresh_token){ } **/ function user($id){ $params=array(); $url='https://api.instagram.com/v1/users/'.$id.'/'; return $this->api($url, $params); } function user_media($id, $count=10, $max_id=''){ $params=array( 'count'=>$count ); if($max_id!='')$params['max_id']=$max_id; $url='https://api.instagram.com/v1/users/'.$id.'/media/recent/'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: instagramPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
12. [文件] Facebook ~ 2KB
<?php /** * PHP Library for facebook.com * * @author PiscDong (http://www.piscdong.com/) */ class facebookPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope ); return 'https://graph.facebook.com/oauth/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://graph.facebook.com/oauth/access_token'; return $this->http($url, http_build_query($params), 'POST'); } /** function access_token_refresh($refresh_token){ } **/ function me(){ $params=array(); $url='https://graph.facebook.com/me'; return $this->api($url, $params); } function my_feed($count=10, $page=1){ $params=array( 'page'=>$page, 'count'=>$count ); $url='https://graph.facebook.com/me/feed'; return $this->api($url, $params); } function update($content){ $params=array( 'message'=>$content ); $url='https://graph.facebook.com/me/feed/'; return $this->api($url, $params, 'POST'); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: facebookPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
13. [文件] 360 ~ 2KB
<?php /** * PHP Library for 360.cn * * @author PiscDong (http://www.piscdong.com/) */ class o360PHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url){ $params=array( 'response_type'=>'code', 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url ); return 'https://openapi.360.cn/oauth2/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://openapi.360.cn/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } function access_token_refresh($refresh_token){ $params=array( 'grant_type'=>'refresh_token', 'refresh_token'=>$refresh_token, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret ); $url='https://openapi.360.cn/oauth2/access_token'; return $this->http($url, http_build_query($params), 'POST'); } function me(){ $params=array(); $url='https://openapi.360.cn/user/me.json'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result=$this->http($url.'?'.http_build_query($params)); }else{ $result=$this->http($url, http_build_query($params), 'POST'); } return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: o360PHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); $json_r=array(); if($response!='')$json_r=json_decode($response, true); return $json_r; } }
14. [文件] github.php ~ 2KB
<?php /** * PHP Library for github.com * * @author PiscDong (http://www.piscdong.com/) */ class githubPHP { function __construct($client_id, $client_secret, $access_token=NULL){ $this->client_id=$client_id; $this->client_secret=$client_secret; $this->access_token=$access_token; } function login_url($callback_url, $scope=''){ $params=array( 'client_id'=>$this->client_id, 'redirect_uri'=>$callback_url, 'scope'=>$scope ); return 'https://github.com/login/oauth/authorize?'.http_build_query($params); } function access_token($callback_url, $code){ $params=array( 'code'=>$code, 'client_id'=>$this->client_id, 'client_secret'=>$this->client_secret, 'redirect_uri'=>$callback_url ); $url='https://github.com/login/oauth/access_token'; $result_str=$this->http($url, http_build_query($params), 'POST'); $json_r=array(); if($result_str!='')parse_str($result_str, $json_r); return $json_r; } /** function access_token_refresh($refresh_token){ } **/ function me(){ $params=array(); $url='https://api.github.com/user'; return $this->api($url, $params); } function api($url, $params, $method='GET'){ $params['access_token']=$this->access_token; if($method=='GET'){ $result_str=$this->http($url.'?'.http_build_query($params)); }else{ $result_str=$this->http($url, http_build_query($params), 'POST'); } $result=array(); if($result_str!='')$result=json_decode($result_str, true); return $result; } function http($url, $postfields='', $method='GET', $headers=array()){ $ci=curl_init(); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ci, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ci, CURLOPT_TIMEOUT, 30); if($method=='POST'){ curl_setopt($ci, CURLOPT_POST, TRUE); if($postfields!='')curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } $headers[]="User-Agent: githubPHP(piscdong.com)"; curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLOPT_URL, $url); $response=curl_exec($ci); curl_close($ci); return $response; } }
15. [代码]示例文件,以新浪微博为例,其他平台方法类似
/** * 示例文件,以新浪微博为例,其他平台方法类似 */ //生成登录链接 require_once('sina.php'); $app_key=''; //新浪微博应用App Key $app_secret=''; //新浪微博应用App Secret $callback_url='http://yoururl/sina_callback.php'; //回调网址,请根据自己的实际情况修改 $sina=new sinaPHP($app_key, $app_secret); $login_url=$sina->login_url($callback_url); //生成登录链接,部分平台需要权限,格式请参考各平台api文档 echo '<a href="'.$login_url.'">点击进入授权页面</a>'; //授权回调页面,即生成登录链接时的$callback_url require_once('sina.php'); $app_key=''; //新浪微博应用App Key $app_secret=''; //新浪微博应用App Secret $callback_url='http://yoururl/sina_callback.php'; //回调网址,必须和生成登录链接时相同 if(isset($_GET['code']) && $_GET['code']!=''){ $sina=new sinaPHP($app_key, $app_secret); $result=$sina->access_token($callback_url, $_GET['code']); //获取access token /** * $result['access_token'],用户access token * $result['expires_in'],access token的有效期,单位:秒 * 部分平台会有$result['refresh_token'],refresh token,access token到期后使用refresh token生成新的access token * 腾讯微博还需要保存$_GET['openid'] */ } //用户登录授权后操作api require_once('sina.php'); $app_key=''; //新浪微博应用App Key $app_secret=''; //新浪微博应用App Secret $access_token=''; //授权回调页面生成的用户access token $sina=new sinaPHP($app_key, $app_secret, $access_token); //腾讯微博还需要openid,授权回调页面保存的$_GET['openid'] $sina_uid=$sina->get_uid(); //登录用户uid //其他功能请参考sina.php自行使用,或者根据api文档自行添加 //其他平台的使用方法和新浪微博类似,各种api的返回数据格式各有不同,请自行参考各平台的api文档 //支持refresh token的平台在access token到期后请使用access_token_refresh()生成新的access token
来源:http://www.oschina.net/code/snippet_930167_16877#28044
相关推荐
网易微博、百度、Google、微软、Instagram、Facebook、360、GitHub、淘宝等平台的账号登录及api操作,使用oauth 2.0。官方提供的sdk都太过庞大,这是我自己简化的,提供简单的账号登录、获取个人信息、发布微博等...
在sns-login中,OAuth是实现用户通过社交账号登录的关键技术。 2. **API接口**:社交网络平台通常提供API(Application Programming Interface),允许开发者调用获取用户信息、授权等功能。例如,微信开放平台、...
【国内主流SNS网站分析与数据整理】 社交网络服务(SNS)自2008年起在中国互联网领域迅速崛起,催生了一批诸如校内、占座、海内、开心、一起、蚂蚁、豆瓣、5G、TW等众多平台,形成了激烈的市场竞争格局。这些SNS...
【标题】"校内网开放平台API (.net)" 涉及的是针对校内社交网络平台的API接口的.NET实现,这些接口允许开发者利用.NET框架来与校内网的开放平台进行交互,实现各种功能扩展。 【描述】指出,这个.NET封装提供了开源...
- **开放登录(Open Login)**:如使用第三方账号直接登录某平台。 - **开放数据源(Open Data Source)**:开放平台通过向第三方应用提供数据,丰富自身服务内容。 - **开放应用(Open App)**:允许第三方...
开放API已成为互联网服务的重要组成部分,不仅提升了平台的功能性和用户体验,还促进了开发者社区的繁荣和发展。随着技术的不断进步,未来将会有更多领域采用开放API模式,进一步推动整个行业的创新和发展。
《SNS网站及用户分析报告》是一份深入探讨社交网络服务(Social Networking Service,简称SNS)领域的专业报告。这份报告全面涵盖了SNS的基本概念、当前的发展状况、用户行为分析、网站功能解析以及盈利模式与前景...
在互联网社交领域,分享内容到不同的社交网络服务(SNS)平台已经成为用户日常互动的重要组成部分。`share.js` 是一个专为此目的设计的JavaScript插件,它允许开发者轻松地将自定义分享功能集成到他们的网站中,使得...
由于浏览器的安全限制,可能需要使用JSONP或CORS来处理跨域请求,以便与第三方SNS平台的API通信。 9. **数据追踪与分析**: 自定义分享可能还包括集成分析工具,如Google Analytics,来追踪分享的次数、来源和...
SNS2124&SNS2224&SNS2248&SNS3096&SNS5192&SNS5384产品文档
然而,部分SNS平台在深层次知识的展示、技术支撑和交互效能方面仍有待提升,部分网络学习者仍停留在浅层学习阶段。 【关键词】涉及的SNS平台、深度学习、Web 2.0和高阶思维,突显了研究的重点。Web 2.0时代的到来,...
在当今的互联网时代,SNS(Social Networking Service,社交网络服务)已经成为人们生活中不可或缺的一部分。SNS平台通过提供一个互动、分享和交流的在线环境,使得用户能够建立和维护关系网络。本文将探讨SNS的发展...
技术上,需要整合SNS平台的开放API,实现用户数据的同步和交互;大数据分析技术用于挖掘用户行为模式;云计算支持大规模的用户服务和数据处理;以及先进的安全技术确保交易过程的安全。 7. 市场机会与挑战: 市场...
基于SNS网络的电子商务案例分析可以看出,SNS平台已经成为电子商务的重要组成部分。企业可以通过SNS平台来宣传自己的品牌和产品,提高用户体验和忠诚度,提高销售额和市场份额。同时,SNS平台也可以为用户提供更多的...
- 列出了与Amazon SNS相关的API操作,如创建、删除主题、订阅等。 6. 使用IAM和Amazon SNS策略 - 阐述了如何将IAM(Identity and Access Management)与SNS策略结合使用,以管理对AWS资源的精细访问控制。 7. ...
iwebSNS是一款功能强大且易于扩展的LAMP开源社交网络平台。 它基于iweb SuperInteraction(简称iweb SI)框架开发。借助iwebSI平台,站点可以轻松获得支持热插拔及快速增加新节点的集群计算与处理能力(分布式计算与...
对于其他平台,如Instagram,可能需要模拟登录和模拟用户操作,因为它们对非官方API有更严格的限制。 除了直接使用API,还可以结合使用Python的其他库,如`pandas`进行数据清洗和分析,`matplotlib`或`seaborn`绘制...
电子商务案例分析:SNS平台案例.ppt
这通常通过OAuth(开放授权)协议实现,用户需要在SNS网站上登录他们的MSN账号,并授权网站访问其联系人列表。OAuth允许第三方应用代表用户与资源服务器进行交互,同时保护了用户的账号信息不被泄露。 在技术实现上...