这段asp怎么写成php的

cxycxycxyc 2009-07-24 04:00:56
<%@ CODEPAGE=936 %>

<%
If Request("submit")<>"" Then

Dim xmlhttp
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")

Response.Cookies("save_username")=Request("username")
Response.Cookies("save_username").Expires=Date+365
Response.Cookies("save_password")=Request("password")
Response.Cookies("save_password").Expires=Date+365
username = Request("username")
password = Request("password")

post_status = "status=" + server.URLencode(Request("updateStatus"))

If Request("twitter") = 1 Then
xmlhttp.Open "POST", "http://" & username & ":" & password & "@twitter.com/statuses/update.xml", False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=gb2312"
xmlhttp.setRequestHeader "Content-Length", Len(post_status)
xmlhttp.Send (post_status)
Response.Write "twitter OK." 'xmlhttp.responseText
End If
是同步twitter的代码,怎么写成php的,或者谁有现成的同步代码
...全文
104 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
程序猿之殇 2009-07-24
if($_POST['submit') <> "")
{
set_cookie("save_username", $_POST['username'], time()+365);
set_cookie("save_password", $_POST['password'], time()+365);
$username = $_POST["username"];
$password = $_POST["password"];
$status = "status=" . urlencode($_POST['updateStatus']);
if($_POST['twitter'] == 1)
{
$ch = curl_init();
//设置URL,POST方式提交以及POST数据
curl_setopt($ch, CURLOPT_URL, $searchURL);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_URL, sprintf("http://%s:%s@twitter.com/statuses/update.xml", $username, $password));
curl_setopt($ch, CURLOPT_POSTFIELDS, sprintf("status=%s", $status));
$header = array('Accept: application/x-www-form-urlencoded; charset=gb2312');
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);

$result = curl_exec($ch);
}
}
回复
eimhee 2009-07-24
xmlhttp是Ajax 中的内容,怎么变成ASP中的呢
回复
发动态
发帖子
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
社区公告
暂无公告