2 qq 30332497 qq_30332497 于 2016.09.08 21:34 提问

nginx PHP CURL POST出错

想要实现七牛云存储直接远程存储图片
在本地测试是可以的,但是一到线上的服务器(使用LuManager配置的环境)
就出错
错误信息

 HTTP/1.1 400 Bad Request Server: nginx Date: Thu, 08 Sep 2016 11:04:52 GMT Content-Type: text/html Content-Length: 166 Connection: close

PHP代码

 <?php
 function QiNiu_send($imgurl, $title='') { 
    global $access_key,$secret_key;
    $fetch = urlsafe_base64_encode($imgurl);  
    $key = $title.'.jpg';
    $to = urlsafe_base64_encode('bucket:'.$key.'');  
    $url  = 'http://iovip.qbox.me/fetch/'. $fetch .'/to/' . $to;  
    $access_token = generate_access_token($access_key, $secret_key, $url);  
    $header[] = 'Content-Type: application/json';  
    $header[] = 'Authorization: QBox '. $access_token;  

    $curl = curl_init($url);  
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
    curl_setopt($curl, CURLOPT_HEADER,1);  
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);  
    curl_setopt($curl, CURLOPT_POST, 1);  
    curl_setopt( $curl , CURLOPT_TIMEOUT, 1 ); 
    $con = curl_exec($curl);  
    curl_close( $curl ); 

    if ($con === false) {  
        echo 'CURL ERROR: ' . curl_error($curl);  
    } else {  
        //$arr = json_decode($con,true);
        print_r($con);
        return 'http://upload.uuaauu.com/'.$key;  
    }  
} 
?>

1个回答

zhongxiashuhan
zhongxiashuhan   2016.09.11 21:48

服务器的IP有没有被对方限制?

Csdn user default icon
上传中...
上传图片
插入图片