365建站软件在发布文章的时候已集成了原创内容功能选项功能,如下
如果以上功能不满足用户的需求或者有部分用户要使用其它接口来处理发布的文章,就可以采用此接口来处理
通过采集后的文章变量为 $body, 直接将对应接口的php源码内容写入文本框中即可
5118接口实例 如下:
- <?php
- //title 标题api
- $host = "http://apis.5118.com";
- $path = "/wyc/title";
- $method = "POST";
- $apikey = "你要调用API的apikey";
- $headers = array();
- array_push($headers, "Authorization:" . $apikey);
- //根据API的要求,定义相对应的Content-Type
- array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
- $querys = "";
- $titles = "txt=".urlencode($body);
- $url = $host . $path;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_FAILONERROR, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_HEADER, false);
- if (strstr($host, "https://"))
- {
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- }
- curl_setopt($curl, CURLOPT_POSTFIELDS, $titles);
- $titlearr=json_decode(curl_exec($curl),true);
- //$body=json_decode(addslashes(curl_exec($curl)),true);
- $title=$titlearr['data'];
- //body 内容api
- $host = "http://apis.5118.com";
- $path = "/wyc/rewrite";
- $method = "POST";
- $apikey = "你要调用API的apikey";
- $headers = array();
- array_push($headers, "Authorization:" . $apikey);
- //根据API的要求,定义相对应的Content-Type
- array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
- $querys = "";
- $bodys = "txt=".urlencode($body);
- $url = $host . $path;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_FAILONERROR, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_HEADER, false);
- if (strstr($host, "https://"))
- {
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- }
- curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
- $bodyarr=json_decode(curl_exec($curl),true);
- $body=addslashes($bodyarr['data']);
- ?>
复制代码
以上为参考代码,接口的代码以提供方为准
注意事项:
如果使用了其它的接口,相当于每次在发布 文章时都为调用一次接口,如果连接接口的速度慢,会影响发布效率!
|
|