Websites with good website quality can see the real-time push function under the Baidu Webmaster Platform/Data Submission/sitemap column. This tool is currently open to invitations. Baidu’s real-time push API interface can push our newly published articles in real time. , ensuring that Baidu will include it as soon as possible.
Baidu Webmaster Platform http://zhanzhang.baidu.com/
Open Baidu Webmaster Platform, click on the add new data interface of real-time push to get the api push address with token:
http://ping.baidu.com/sitemap?site=www.yourdomain.com&resource_name=sitemap&access_token=xxxxxxx
Share a piece of php real-time push code written by a netizen:
PHP pushes newly published articles in real time
Socketopen method to push sitemap
$send .= "Connection: Closernrn";
fputs ( $io, $send );
$return = '';
while ( ! feof ( $io ) )
{
$return .= fread ( $io, 4096 );
}
return $return;
}else{
return false;
}
}
$return = sitemap_ping_baidu(array('http://www.yourdomain.com/a.php?id=1'));
The xml document that Baidu will return after pushing
Your question is too crude. Different API interfaces provide different calling and usage methods. Under normal circumstances, the API provider will provide corresponding instructions and examples.
After you have a developer account, enter the Baidu Open Cloud Platform. The following URL is the development guide: developer.baidu.com/...qq.c2c. In principle, you can successfully run the sample program provided by Baidu according to this guide, but I personally feel that it is not detailed enough, so I wrote the following steps based on my own experience.
After entering the website as shown above, click Login in the upper right corner. After success, the management console will be displayed in the upper right corner. Click the management console to enter the light application management, and then click the arrow in the picture to display the mobile application management classification as shown in Figure 1.1. Click the mobile application management to enter the application management.
Click to enter the following interface, fill in the application name, such as Push Test 2, and click Save.
Click on the management console to enter the light application management, and then click on the arrow in the picture to display the mobile application management classification in Figure 1.1. Click on the developer service management to enter Figure 1.4. The push test 2 is the newly created one. .
Figure 1.4 Developer Service Management
Click Push Test 2 to enter the red circle ID in Figure 1.5 and record the ID in the red circle, which will be written into the program later.
Figure 1.5 Basic information
package="com.baidu.push.example"
Figure 1.6 Push settings
You may not know the application package when you use it for the first time. What is the name? Let’s first introduce the SDK of Baidu Cloud Push. Download the android version of the client SDK package and application demo from this website: developer.baidu.com/...entsdk. Next, unzip the package directory as follows\Baidu-Push-SDK-Android-L2-3.2.0\Demo, and import the Demo into eclipse. If there is an editor
translation report, just change the encoding to UTF-8, and generally there will be no error. In this way, if you run the sample program on your mobile phone, you will find that the program cannot receive push notifications from Baidu Cloud. This is because the value of api_key in mainfest.xml needs to be modified, which is the basic information API key in test 2 just pushed. See the red circle in Figure 1.5. My modifications are as follows:
Run it again to receive messages pushed by Baidu Cloud. The next section introduces the detailed testing process.
Run the pushdemo software on your mobile phone, enter Baidu Cloud Developer Service Management, and select the push test 2 just now in the project name. Click on the cloud push on the left as shown in Figure 1.7;
Click on the notification to enter the following Figure 1.8. Fill in the relevant content in the title and message content. The last and most critical time has arrived. It is best to run the pushdemo to the background or exit, so Only then can you feel the push function more vividly. Click Send in the picture. In about 1 second, you will hear a sound, indicating that you have received the push. As shown in Figure 1.9, the test result. This message is the same as in Figure 1.8. The content does not correspond because the results are mine the next day. I won’t talk about the testing of messages and media. I’ve tested it and it should be OK.