GithubHelp home page GithubHelp logo

libweibo's Introduction

说明

用于新浪微博开放平台的PHP SDK. 内含能直接使用的DEMO.

SAE(Sina App Engine, http://www.sinacloud.com )已内置SDK,不需要下载,使用前需要手工调用 require_once('saetv2.ex.class.php');

composer

composer.phar require xiaosier/libweibo:dev-master

微博写入接口说明

由于微博开放平台调整,写入接口需要都切换到share分享接口,说明在 http://open.weibo.com/blog/%E3%80%90%E5%B9%B3%E5%8F%B0%E5%85%AC%E5%91%8A%E3%80%91%E5%BE%AE%E5%8D%9A%E5%BC%80%E6%94%BE%E5%B9%B3%E5%8F%B0%E5%88%86%E4%BA%AB%E5%88%B0%E5%BE%AE%E5%8D%9A%E6%8E%A5%E5%8F%A3%E5%8D%87%E7%BA%A7%E5%85%AC 这里。 调用时需要使用$instance->share($status, $pic); 方法,示例:

$c = new SaeTClientV2( WB_AKEY , WB_SKEY , WB_ACCESSTOKEN );
// 待发送的文字内容
$status = '发送的文字内容';
// 本地一张图片,也可以不带图片
$file_local = '5486087cly1fhh2yaksr1j20j60srtd0.jpg';
// 拼接'http://weibosdk.sinaapp.com/'是因为这个share接口至少要带上一个【安全域名】下的链接。
$ret = $c->share($status.'http://weibosdk.sinaapp.com/', $file_local);
var_dump($ret);

更新

  • 2017年7月14日 增加分享接口
  • 2013年2月20日 修改V2版一处notice
  • 2011年12月16日 修改V2版两处手误
  • 2011年10月21日 发布V2版PHP SDK,基于 http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2 中的最新接口封装。
  • 2011年6月16日 发布OAuth2版PHP SDK,删除Basic认证的SDK(微博开放平台已不支持Basic认证)
  • 2010年11月17日 修改了demo程序默认callback url在某些访问方式下不正确的问题.
  • 2010年6月29日Basic认证版本&OAuth版本添加verify_credentials函数,用于获取当前用户信息,OAuth添加update_avatar更新头像
  • 2010年5月5日 Basic 认证版本添加图片发布支持
  • 2010年5月12日 OAuth 认证版本添加图片支持

说明

Demo演示地址

如何申请API Key

你需要有一个新浪微博开放平台的API Key.这里申请: http://open.weibo.com

关于Class的功能

  • 基于OAuth认证.
  • 完成至2011年10月21日止,全部接口的封装

新浪微博V2版PHPSDK Demo使用教程

  • 1.在open.weibo.com创建应用,得到API KEY,设置“授权设置”中的“应用回调页”地址为"http://host/callback.php",其中host为网站域名。
  • 2.下载Demo,然后解压,修改config.php中的WB_AKEY为App Key,WB_SKEY为App Secret,WB_CALLBACK_URL为刚才填入的回调页地址。
  • 3.上传到PHP空间即可

新浪微博站内应用Demo使用教程

  • 1.在open.weibo.com创建站内应用,得到API KEY
  • 2.编辑应用属性,设置"应用页面"中的“站内应用地址”
  • 3.下载,解压,修改config.php中的WB_AKEY为App Key,WB_SKEY为App Secret,CANVAS_PAGE为“应用页面”中设置的”站内应用地址“
  • 4.上传代码到PHP空间
  • 5.编辑应用属性,设置"应用页面"中的"应用实际地址"为刚刚上传代码的apps.php的地址,比如:"http://xxxxx.sinaapp.com/apps.php",设置“Iframe高度“为2000px。
  • 6.访问刚刚设置的“站内应用地址”即可。

OAuth版Demo使用教程

  • 1.在open.weibo.com创建应用,得到API KEY
  • 2.下载,然后解压,修改config.php中的WB_AKEY为App Key,WB_SKEY为App Secret。
  • 3.上传到PHP空间即可

Bug tracker

Have a bug? Please create an issue here on GitHub!

https://github.com/xiaosier/libweibo/issues

Authors

License

Copyright 2011 SINA, Inc. Copyright 2011 SAE

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

libweibo's People

Contributors

custool avatar nickzhuo avatar xiaosier avatar xutengfei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libweibo's Issues

接口更新之后搜索api返回错误代码21409

调用search_statuses_high函数的时候返回
array(2) {
'error_code' =>
int(21409)
'error' =>
string(21) "illegal sid or no sid"
}
这个错误,查了文档,并没有收入这个错误,不知该如何解决?
这个sdk还会继续更新吗(⊙_⊙)

["error"]=> string(21) "text not find domain!" ["error_code"]=> int(10017)

一直报错

demo

$c = new SaeTClientV2( WB_AKEY , WB_SKEY , WB_ACCESSTOKEN );
// 待发送的文字内容
$status = '发送的文字内容';
// 本地一张图片,也可以不带图片
$file_local = '5486087cly1fhh2yaksr1j20j60srtd0.jpg';
// 拼接'http://weibosdk.sinaapp.com/'是因为这个share接口至少要带上一个【安全域名】下的链接。
$ret = $c->share($status.'http://weibosdk.sinaapp.com/', $file_local);
var_dump($ret);

也是报错,安全域名已经添加了,urlencode也试过了

upload_url_text提交总是提示10016,经过调试结果太坑爹了

` ``php
/**
* 指定一个图片URL地址抓取后上传并同时发布一条新微博
*
* 对应API:{@link http://open.weibo.com/wiki/2/statuses/upload_url_text statuses/upload_url_text}
*
* @param string $status 要发布的微博文本内容,内容不超过140个汉字。
* @param int $visible 微博的可见性,0:所有人能看,1:仅自己可见,2:密友可见,3:指定分组可见,默认为0
* @param string $list_id 微博的保护投递指定分组ID,只有当visible参数为3时生效且必选。
* @param string $pic_id 已经上传的图片pid,多个时使用英文半角逗号符分隔,最多不超过9个。
* @param float $lat 纬度,有效范围:-90.0到+90.0,+表示北纬,默认为0.0。
* @param float $long 经度,有效范围:-180.0到+180.0,+表示东经,默认为0.0。
* @param string $annotations 元数据,主要是为了方便第三方应用记录一些适合于自己使用的信息,每条微博可以包含一个或者多个元数据,
* 必须以json字串的形式提交,字串长度不超过512个字符,具体内容可以自定。
* @param string $url 图片的URL地址,必须以http开头。
* @return array
*/
function upload_url_text( $status, $url , $visible=0, $list_id=NULL, $pic_id=NULL, $lat = NULL, $long=NULL, $annotations=NULL)
{
$params = array();
$params['status'] = $status;
$params['url'] = $url;
$params['visible'] = $visible;
if (!is_null($list_id)) {
$params['list_id'] = $list_id;
}
if (!is_null($pic_id)) {
$params['pic_id'] = $pic_id;
}
if (!is_null($lat)) {
$params['lat'] = $lat;
}
if (!is_null($long)) {
$params['long'] = $long;
}
if (!is_null($annotations)) {
$params['annotations'] = $annotations;
}
return $this->oauth->post( 'statuses/upload_url_text', $params, true);
}


无论怎么改,怎么抓包,怎么调试信息,都提示没有提交status
返回结果
{"error":"miss required parameter (status), see doc for more info.","error_code":10016,"request":"/2/statuses/upload_url_text.json"}

最后发现需要修改SDK,post最后一个参数应该改为false。

默认使用
Content-Type: multipart/form-data
但是这里应该改用
Content-Type:application/x-www-form-urlencoded

奇怪的问题,同样的代码,upload却能接收参数。

个人实名认证的“网站接入”,拿不到access_token

code可以拿到,但是callback.php报错:
SaeTOAuthV2->getAccessToken('code', Array) 授权失败
网站应用里,授权回调和安全域名设置都是对的。
代码是把gihub上的源码config参数修改了,其他没动过
请问有人知道原因吗?

多图怎么发送

单图不管是本地还是在线都能发布成功通过 share($status, $pic = false, $rip = false) 想问一下 多图这个$pic需要怎么样的格式 ?

求助:get access token failed.

=====post data======
string(192) "client_id=1688866701&client_secret=******&grant_type=authorization_code&code=5209649ceb42048370eac2e6c4146f2c&redirect_uri=http%3A%2F%2Fzhubo.baidu.com%2Fadmin%2Finfo"
=====headers======
Array
(
[0] => API-RemoteIP: 10.92.71.24
)
=====request info=====
Array
(
[url] => https://api.weibo.com/oauth2/access_token
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.000189
[namelookup_time] => 0.004267
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
(
)
[primary_ip] => 180.149.135.176
[redirect_url] =>
)

直播接入

你好,我用你的代码授权成功了,我不知道怎么获取用户信息,我现在想要接入微博直播的接口,请问up主可以指点一下吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.