2

我代表他们通过我的应用程序将图像发布到用户墙上(他们在活动中走到镜头前)。我的应用程序上周成功运行,现在它无法运行并报告“在等待出色响应时获得 EOF”。

有一个相关的错误报告,但它是针对 iphone 应用程序的,而我的是基于 Web 的 php。

任何人都可以阐明此错误消息吗?我的代码在下面,但它在图片处理和数据库调用方面分解了很多..

//initial calling code

$data = array('title' => $station_info->title,
              'message' => $station_info->message,
              'token' => $result['access_token'],
              'item' => $item,
              'pic_source' => $image,
              'fb_id' => $result['fb_id'],
              'album_id' => $station_info->pic_station_album_id,
              'user_id' => $user_id_data['id'],
              );

//$result = $this->__do_facebook_image_post($data);     
$feedback = "FACEBOOKIMG: " . $this->__do_facebook_image_post($data, 'x');  

///processing code


private function __do_facebook_image_post($data,$type = "normal"){

        $attachment =  array(
                'title' => $data['title'],
                'message' => $data['message'],
                'token' => $data['token']
        );

        if($type =="normal"){

            $folder = "webcam";
        }else if($type="x"){
            $folder = "x";

        }


        $upload_path = FCPATH . "/pic_uploads/".$folder."/".$data['item'];

        echo $upload_path;


        if(is_file($upload_path))
        {       
            $attachment['source'] =  '@' . realpath(FCPATH . "/img_uploads/".$folder."/". $upload_path);            
        }
        else
        {           
            $attachment['source'] =  '@' . realpath(FCPATH . "/img_uploads/".$folder."/". $data['pic_source']);         
        }

        return $this->facebook_img_post($data['fb_id'],$attachment,$this->__get_facebook_album_id($data['album_id'],$data['user_id'],$data['token']),$data['token']);

    }



private function __do_facebook_image_post($data,$type = "normal"){

        $attachment =  array(
                'title' => $data['title'],
                'message' => $data['message'],
                'token' => $data['token']
        );

        if($type =="normal"){

            $folder = "webcam";
        }else if($type="x"){
            $folder = "x";

        }


        $upload_path = FCPATH . "/pic_uploads/".$folder."/".$data['item'];

        echo $upload_path;


        if(is_file($upload_path))
        {       
            $attachment['source'] =  '@' . realpath(FCPATH . "/img_uploads/".$folder."/". $upload_path);            
        }
        else
        {           
            $attachment['source'] =  '@' . realpath(FCPATH . "/img_uploads/".$folder."/". $data['pic_source']);         
        }

        return $this->facebook_img_post($data['fb_id'],$attachment,$this->__get_facebook_album_id($data['album_id'],$data['user_id'],$data['token']),$data['token']);

    }


private function __post_to_facebook($url,$attachment)
    {   
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // This i added as the URL is https
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);      // This i added as the URL is https
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_POST, true); // Do I need this ?
        curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
        $result= curl_exec($ch);
        curl_close ($ch);   

        return $result;
    }

    function facebook_img_post($fb_id,$data,$album_id ='')
    {


        if(!empty($album_id)){
            $url = "https://graph.facebook.com/".$album_id."/photos";   
        }else{
            $url = "https://graph.facebook.com/".$fb_id."/photos";
        }       

        $attachment =  array(
            'access_token' => $data['token'],
            'message'=> $data['message'],
            'source' => $data['source'] . ";type=".get_mime_by_extension($data['source'])
        );

        return $this->__post_to_facebook($url,$attachment);     
    }
4

1 回答 1

0

返回的错误消息与问题并不真正匹配。

我在尝试上传照片但未传递正确的文件路径时修复了此错误。

于 2012-07-09T11:05:36.917 回答