簡體   English   中英

在wordpress中使用curl_setopt的替代方法

[英]alternative of curl_setopt in wordpress

我有這段代碼使用curl替換了刪除圖像,它可以正常工作,但是我想使用wordpress本機函數來完成此操作。

function image( $destination_path, $remote_image_link ) {
    $ch =  curl_init( $remote_image_link );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    $result = curl_exec( $ch );

    if ( $result ) {
        $rv = file_put_contents( $destination_path, $result );
    }
}

想要用wp_remote或其他一些功能實現相同的wp_remote 。任何幫助都會很棒

答案很簡單。

wp_remote_get輸出是一個大數組,並且在該數組主體中包含主要細節,因為在這里,我只有一個鏈接只需要執行

$result = wp_remote_get($remote_image_link['body']); 

希望它能幫助某人,因為wp文檔尚不清楚

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM