以服务于中国广大创业者为己任,立志于做最好的创业网站。

标签云创业博客联系我们

导航菜单

twitter使用代理

使用代理

,,

提供的另一个很棒的功能是测试两个人之间的友谊的能力。我的意思是测试两个人是否彼此跟随而不是测试一个人是否在用垃圾邮件向世界发送垃圾邮件。与其他所有调用一样使用PHP轻松执行此测试。

PHP()

/**/$person1davidwalshblog$person2mootools/*sendrequesttotwitter*/$urlhttp://twitter.com/friendships/exists$formatxml/*check*/$persons12make_request($url...$format.?user_a.$person1.user_b.$person2);$resultget_match(/friends(.*)\/friends/isU,$persons12);echopreAmIfriendswithmootools?.$result./pre//returnstrueorfalse/*makestherequest*/functionmake_request($url){$chcurl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);$resultcurl_exec($ch);curl_close($ch);return$result;}/*getsthematch*/functionget_match($regex,$content){preg_match($regex,$content,$matches);return$matches[1];}

Thatsit.IdidntuseSimpleXMLinmyexamplebecauseofthesmallsizeofthereturnXML.Toomuchextraoverhead.HerestheXMLsampleresponse:

而已。由于返回XML的大小较小因此我在示例中未使用SimpleXML。过多的额外开销。这是XML示例响应

friendstrue/friends

TheTwitterAPIisfun,isntit?

TwitterAPI很有趣不是吗