09-03-10
上个月就嚷嚷着要自己写个博客,可在诸多借口的掩护下被我拖到了现在。还好,还没放弃,而且看上去还不错。
一直在给别人做策划,对自己的博客却总是随着性子来,所以一直挺萧条。所以这次就正儿八经的给自己做了回策划,从内容、受众到技术应用及风格设计,弄得挺简单但很清晰,用Freemind做的,这东东还被我用来做TODO List,哈哈~~很方便哟~~
由于用的是WIN主机,而且还签了好些年,现在虽然后悔了,可上哪买那后悔的药啊。没事儿,URL-REWRITE是没指望了,但好在空间足,空间换时间,生成HTML吧!
阅读全文 »
09-03-07
So for today’s blog post I am going to show you how you can use jQuery, PHP and a little ajax to connect up to the Twitter API and return results. I’ll cover off unauthenticated calls today to the search API, and follow up with the authenticated piece a little later, so watch out for that!
PHP using cURL
So, in order for us to talk to the Twitter API, we need to use cURL. This isn’t a hard and fast rule, but it sure does make our lives easier. The cURL library should be installed as part of your PHP installation, but do check.
cURL allows us to make a simple call to the Twitter API, and grab some results back if necessary. I’ll be using XML to return results for this demo, but you can use JSON if you want. Anyway, without further ado, here is a nice piece of PHP code to talk to the Twitter Search API – so create a file called getSearch.php :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| < ?php
$query = $_POST['query'];
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://search.twitter.com/search.atom?q=" . urlencode($query) . "&amp;amp;rpp=10");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
header('Content-Type: application/xml; charset=ISO-8859-1');
print $result;
?> |
阅读全文 »
09-02-23
在寻觅Twitter API无果后,我最终投入了饭否的怀抱,很温暖,很快速。一切都是中文的,再不用我那蹩脚的英文了;一切都是很快速,再也不用一次操作等半天了。
在网上看到评论说,饭否的API很像Twitter,我想大概吧,毕竟儿子像父亲没什么不对,优秀的就继承吗,然后再发展自己的特点。
饭否的API中我只测试了三个:
- 显示用户和好友的消息: http://api.fanfou.com/statuses/friends_timeline.[json|xml|rss]
- 显示发给当前用户的消息: http://api.fanfou.com/statuses/replies.[json|xml|rss]
- 发布消息: http://api.fanfou.com/statuses/update.[json|xml]
阅读全文 »
09-02-11
PS:先要郁闷一下,前两天才说要写个自己的博客,可是现在就出状况了,API~~~~A屁哀呀~~~
程序架构和数据库结构已经规划好了,正想着如何应用那些API的时候,头一个Twitter就所我给涮了,貌似Twitter怕自己的服务器消耗过大,限制了第三方API的使用,而且最惨的是我连它的WIKI都进不去,更别提要功能实现了。思来想去还是决定用回国产的Twitter替代品饭否吧,其实饭否也不错,而且国内很多大鸟都用饭否,当然我同样也找到了他们的Twitter =_=!
其实对我来说用什么服务都一样,反正我喜欢尝试,但凡是新产品我都愿意去试用一翻,再与同类型产品做一下比较,适合自己使用习惯的我就会用下去,反之就把它一边吃草去 ^o^
饭否的API文档倒是很清晰的说!