[英]Posting to Twitter/Weibo using PHP without API support (post form spoofing?)
我正在尝试制作一个PHP脚本,该脚本可以发布到中国Twitter克隆新浪微博上的群组。 除了组功能之外,微博在实现上(甚至在API方面)似乎与Twitter几乎相同-因此,我将Twitter作为类比,因为区别与我的问题无关。
我可以通过API进行常规发布,但事实是,微博的API不支持发布到组,这可能是因为可能存在潜在的垃圾邮件危害。 (注意:我的意图不是要用垃圾邮件来发送垃圾邮件,而是要获取一个脚本,以每天自动将有关专利到期的信息发布到相关行业组织。)
现在,我知道应该有一种解决方法,因为有一个应用程序允许一个人手动发布到组(新浪微群自动群发精灵),尽管该源是私有的。 因此,我尝试使用Firebug检查发送到服务器的邮寄表格数据,以查看是否可以通过手动使PHP脚本复制邮寄表格信息来替换API tweet命令,但无济于事。
这是我建立OAuth连接后调用的callback.php文件的代码。 已发布了发布更新的有效API方法,以支持功能不佳的post form方法(在HTML标签中)。
<?php
session_start();
include_once( 'config.php' );
include_once( 'saetv2.ex.class.php' );
$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = WB_CALLBACK_URL;
try { $token = $o->getAccessToken( 'code', $keys ) ; } catch (OAuthException $e) {}
}
if ($token) {
$_SESSION['token'] = $token;
setcookie( 'weibojs_'.$o->client_id, http_build_query($token) );
?><html><head></head><body>
<form action="http://www.weibo.com/aj/mblog/add?__rnd=1340066897833" method="post">
<input type="hidden" name="_surl" value="">
<input type="hidden" name="_t" value=0>
<input type="hidden" name="location" value="home">
<input type="hidden" name="module" value="stissue">
<input type="hidden" name="pic_id" value="">
<input type="hidden" name="rank" value="">
<input type="text" name="text" value="测试发表微博 test message" />
<input type="submit">
</form></body></html><?
/*
$c = new SaeTClientV2( WB_AKEY , WB_SKEY , $_SESSION['token']['access_token'] );
$msg = $c->update("测试发表微博 test message");
if ($msg === false || $msg === null){ echo "Error occured"; return false;}
if (isset($msg['error_code']) && isset($msg['error'])){ echo ('Error_code: '.$msg['error_code'].'; Error: '.$msg['error'] ); return false;}
echo($msg['id']." : ".$msg['text']." ".$msg["created_at"]);
*/
} else echo('授权失败。 authentication failed');
?>
我对所有这些都还很陌生,所以我可能缺少明显的东西,但是在座的人是否对Twitter / Weibo足够了解,可以在这里找到问题所在? 也许有一个简单的解决方法? 谢谢!
已经有一段时间了,但是对于任何绊脚石的人来说:到现在为止我已经了解了一点,并且看起来使用Ruby gem Watir进行浏览器自动化比使用表单欺骗要好得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.