Joke Collection Website - Blessing messages - I have a short message interface provided by mobile. How to call these interfaces to send short messages in php?
I have a short message interface provided by mobile. How to call these interfaces to send short messages in php?
Calling a custom interface usually has the following steps:
1. Read the interface document.
2. The data interface usually provides some parameters. If it is a GET interface, please splice the parameters after the address (recommended
Http_build_query). If it is a POST interface, please see my sample code.
Step 3 request data
4. Parse the returned content and judge whether the call is successful. Usually, the content returned is in xml and json format.
Give you an example of CURL calling POST interface:
& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)
$ch? =? Curl_init ('omit the interface address,? Prevent shielding');
//? The following options are set to true, otherwise the content returned by the interface will be printed directly on the page.
curl_setopt($ch,? CURLOPT_RETURNTRANSFER,? True);
//? Connection timeout, be sure to set it.
curl_setopt($ch,? CURLOPT_CONNECTTIMEOUT,? 5); ?
//? After a successful connection, the request timed out, so it must be set.
curl_setopt($ch,? CURLOPT_TIMEOUT,? 5);
//? Use publish request
curl_setopt($ch,? CURLOPT_POST,? 1);
//? Release parameters,? $post_data is an associative array of parameters.
curl_setopt($ch,? CURLOPT_POSTFIELDS,? $ post _ data);
//? Submit a request and get feedback?
$ response? =? curl _ exec($ ch);
//? Analyze the content of the feedback. If it is SOAP style, please refer to the usage of SoapClient class in PHP document. Because the Soap specification is not uniform, Soap implemented in other languages may not be compatible with PHP.
I have used Monternet's interface before (not the mobile phone interface), which provides two styles of API. Its Soap is not compatible with PHP. So I chose a custom style API.
- Previous article:My friend is in a bad mood. Send a message to comfort him.
- Next article:Why do I need to enter SMS verification code to log in?
- Related articles
- Thank you for giving me a red envelope.
- The girl is angry, how to make her happy …
- Zhangjiakou epidemic prevention station telephone
- Water is pure, there is no fish, and people are mean and invincible. There is a short message with this information in it
- Can the postal bank card be bound to WeChat wallet?
- How to set up traceless interception SMS for LeTV 2 mobile phone?
- Teacher's Day is coming. How to write a short message to my son's teacher?
- How to apologize for peeking at other people's text messages
- Was your car recalled last month?
- Can Jinzhou bank run water be printed online?