WS
Functions
/home/docs/checkouts/readthedocs.org/user_builds/synchronize-wechat/checkouts/latest/insert_by_url.php File Reference

Functions

if(!class_exists('simple_html_dom_node')) sync_wechat_check_wx_url ($url)
 check the domain name More...
 
 sync_wechat_get_html ($url, $timeout=30)
 get the html from url More...
 
 sync_wechat_insert_by_url ($url, $config=Null)
 this function insert wechat article to the wp-database this function relies on global variable $wpdb and the php module $curl More...
 
 sync_wechat_get_publish_date ($html)
 
 sync_wechat_insert_by_html ($html, $config=Null)
 insert $wpdb from html, called by sync_wechat_insert_by_url
 
 sync_wechat_check_image_exists ($postId, $image_name)
 get 1. attached image for $postId, 2. unattached image, and check whether image_name is within it More...
 
 sync_wechat_get_image_extension_from_url ($url)
 guess the image extension from the url More...
 
 sync_wechat_get_image_name ($url, $prefix, $extension_=Null)
 use file content hash to generate image name the image suffix is got from the imageFile. More...
 
 sync_wechat_upload_image ($url, $postId, $image_name=Null)
 download image from $url and update it for the post with id = $postId More...
 
 sync_wechat_set_feature_image ($postId, $feature_image_url, $imageName=Null)
 : set the thumbnail image for the specified post, called by sync_wechat_set_image
 
 sync_wechat_set_image ($html, $postId, $config=Null)
 extract image urls from html, and download it to local file system, update image url in postId->postContent More...
 
 sync_wechat_insert_by_urls ($urls, $config)
 insert url list into $wpdb, calling sync_wechat_insert_by_url
 
 sync_wechat_resolve_bg_image (&$content, $postId)
 resolve css background images, called by sync_wechat_download_image
 
 sync_wechat_resolve_origin ($dom)
 resolve article origin, called by sync_wechat_download_image
 
 sync_wechat_process_video (&$dom)
 resolve tencent video, add width, height, src attribute
 
 sync_wechat_download_image ($postId, $dom, $config=Null)
 download all images in $dom, called by sync_wechat_set_image
 

Function Documentation

◆ sync_wechat_check_image_exists()

sync_wechat_check_image_exists (   $postId,
  $image_name 
)

get 1. attached image for $postId, 2. unattached image, and check whether image_name is within it

Parameters
postIdpost Id
image_nameimage_name to be checked
Returns
$status `{'status_code':$postId, 'err_msg':$err_msg}` if the image exists, set $postId = image attachment id, otherwise set postId = 0

◆ sync_wechat_check_wx_url()

if (!class_exists( 'simple_html_dom_node')) sync_wechat_check_wx_url (   $url)

check the domain name

Parameters
$url
Returns
trimed $url if $url contains the domain name of wx; otherwise, empty string is returned

◆ sync_wechat_get_html()

sync_wechat_get_html (   $url,
  $timeout = 30 
)

get the html from url

Parameters
$url
Returns
$html raw text, no error handling in this function

◆ sync_wechat_get_image_extension_from_url()

sync_wechat_get_image_extension_from_url (   $url)

guess the image extension from the url

Parameters
$urlimage url
Returns
extension name with the dot

◆ sync_wechat_get_image_name()

sync_wechat_get_image_name (   $url,
  $prefix,
  $extension_ = Null 
)

use file content hash to generate image name the image suffix is got from the imageFile.

Parameters
$urlabsolute url of the image file
$prefixprefix to prepend before the image name
Returns
image file name, no error handling.

◆ sync_wechat_insert_by_url()

sync_wechat_insert_by_url (   $url,
  $config = Null 
)

this function insert wechat article to the wp-database this function relies on global variable $wpdb and the php module $curl

Parameters
$config
$config = {
        'changeAuthor'[bool,default:false]:whether to keep the original author
    'changePostTime'[bool,default:false]: whether to keep the original post time
    'postStatus'[choice,default:publish]: article status
      'postType'[choice,default:post]: article type
    'keepStyle'[bool,default:false]: whether the css of the article is kept
      'keepSource'[bool, default:true]: whether the original source info is kept
    'postCate'[choice,default:not_classcified]: the classification to put the article
      'setFeatureImage'[bool,default:true]: whether to set the feature image
      'debug'[bool, default:true]: whether to turn on debug mode, debug mode will output more detailed information
}
Returns
$status
$status = {
    'status_code'[int]: if status_code = 0, error occurs
    'err_msg'[str]: if no error, empty str
}

◆ sync_wechat_set_image()

sync_wechat_set_image (   $html,
  $postId,
  $config = Null 
)

extract image urls from html, and download it to local file system, update image url in postId->postContent

Parameters
$htmlraw html text, $postId: post Id
Returns
status = {'status_code':$postId, 'err_msg':$err_msg}

◆ sync_wechat_upload_image()

sync_wechat_upload_image (   $url,
  $postId,
  $image_name = Null 
)

download image from $url and update it for the post with id = $postId

Parameters
$urlwechat image original url
$postIdpost Id
Returns
$status `status = {'status_code':$postId, 'err_msg':$err_msg}`