Introduction: This is a detailed page of PHP plurk api basics (1). It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 346948 'rolling = 'no'>
PHP plurk api basics (1)-How to be a self-built programmer
1. Step 1
Go to plurk php api Google Code official to get the latest PHP API
The above version is 1.6.2 (it is already the latest version)
Without a waste of traffic to switch to http://www.plurk.com/API/2/ like FB API
2. next, extract the example of the PHP-plurk-API in webserver. PHP, I directly use examples to modify
3. First, completely remove the surface and refine it into the following program:
<? PHP
$ Api_key = ''; // your plurk API key
$ Username = ''; // your plurk ��
$ Password = ''; // your plurk Password
Require ('plurk _ API. php ');
$ Plurk = new plurk_api ();
$ Plurk-> login ($ api_key, $ username, $ password );
?>
4. Go to the plurk API officer to apply for a plurk API key.
Enter the get an API key at the bottom.
The API key is sent to your mailbox and filled in $ api_key.
In this step, you have basically completed the "php API login" operation, and then how to renew it!
5. How to Use the php api?
Enter the following program, and then click "in:
<?
$ Plurk-> add_plurk ('zh-tw ', 'says', 'Hello! ');
?>
"Says: Hello, everyone! "Information
However, when you perform heavy traffic, you will have it once. Because the flood control system is used, the same volume of traffic cannot be used all the time.
6. Judgement and determination by use, and determination by security administrator in the morning and evening:
MySQL table:
Item Name: _ plurk
Item table name (from): _ talk
Item table bit: 1-bit int-level 255 (from): _ time
Program Section:
Backend line (example. php ):
<?
Mysql_connect ("localhost", "root", "123 "); //
Mysql_query ("set names 'utf8'"); // set UTF-8
Mysql_select_db ("_ plurk"); // ��
Date_default_timezone_set ("Asia/Taipei"); // you can call date_default_timezone_set to GMT + 8 in Taipei.
$ Now_time = date ("u", mktime (date ("H"), 0, 0, date ("M"), date ("D "), date ("Y ")));
// The second of the current day
$ Now_hour = date ("G"); // obtain the value of today's hour.
$ Have_post = @ mysql_result (mysql_query ("select * From _ talk where _ time = '$ now_time'"), 0, "_ time "); // check whether there are any items. Avoid repeated items.
If ($ have_post = "") // if it is null, it indicates that there is a condition.
{
Switch ($ now_hour) // you can see what you need when it is!
{
Case 7: $ post = "getting up early"; break;
Case 23: $ post = "late at night, early sleep"; break;
}
$ Plurk-> add_plurk ('zh-tw ', 'says', $ post ); //
Mysql_query ("insert into _ talk (_ time) values ('$ now_time')") // imports
}
?>
I know that PHP is a server-side language, so I don't know how to program self-run ?, With JavaScript Ajax
Program front-end (index. php ):
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> PHP plurk API Autorun </title>
<Script language = "JavaScript" src = "./jquery-1.5.js" type = "text/JavaScript"> </SCRIPT>
</Head>
<Body>
<Script language = "JavaScript">
VaR Total = 0;
Function rload ()
{
$ ("# At" ingress .html ("loading ...");
Total ++;
$. Get (
"./Example. php ",
{Rand: Math. Random ()},
Function (data)
{
$ ("# At" ).html ("the example. php program has been running <u>" + total + "</u> times ");
Rload ();
},
"Html"
)
}
$ (Document). Ready (function (){
Rload ();
});
</SCRIPT>
<Div id = "at">
</Div>
</Body>
</Html>
Use jquery's Ajax line to repeat the line. Click jquery's JavaScript program and place it under the same item.
Use the above method to re-run the program, as long as it stays in the index. PHP, the attacker is in the specified line!
How to use PO next time...
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/346948.html pageno: 4.