Wordpress“download_url”SSL验证

时间:2013-01-09 10:15:55

标签: facebook wordpress ssl

是的,所以我一直在使用Facebook API并且可以确认图像在那里,我正在尝试将其导入Wordpress以将其附加到帖子。

以下是我所拥有的代码,我确定问题出在了。

if (!empty($image)){
                $fql ="SELECT src_big FROM photo WHERE pid = \"$image\"";
                $fql = urlencode($fql);
                $feedurl = "https://graph.facebook.com/fql?q=$fql&access_token=$page_at";
                $feed=file_get_contents($feedurl);
                $feed = json_decode($feed);
                $image = $feed->data[0]->src_big;

                $tmp = download_url( $image );
                $desc = "SocialHub Facebook Image";
                $file_array['name'] = 'Facebook Image '.$postid;
                $file_array['tmp_name'] = $tmp;
                if ( is_wp_error( $tmp ) ) {
                    @unlink($file_array['tmp_name']);
                    $file_array['tmp_name'] = '';
                    echo $tmp->get_error_message();
                }
                // do the validation and storage stuff
                $id = media_handle_sideload( $file_array, $postid, $desc );
                // If error storing permanently, unlink
                if ( !is_wp_error($id) ) {
                    set_post_thumbnail( $postid, $id );
                }else{
                    echo $id->get_error_message().'<br>';
                }
            }

但是在运行时我收到错误消息:

SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

如果有人想到在没有SSL证书错误的情况下下载facebook图片的方法,我们将不胜感激。

提前致谢。

2 个答案:

答案 0 :(得分:1)

这是一个更彻底的解决方法。

add_filter( 'https_local_ssl_verify', '__return_false' );
add_filter( 'https_ssl_verify', '__return_false' );

另见: https://wordpress.stackexchange.com/questions/72529/filter-any-http-request-uri

答案 1 :(得分:0)

没关系,回答我自己的问题; facebook作为所有带有和不带SSL的图像,所以不得不简单地添加:

$image = str_replace('https://','http://',$image);

在使用download_url()函数之前