facebook api返回“在等待未完成的响应时得到EOF”错误消息

时间:2012-06-26 12:53:59

标签: facebook facebook-graph-api

我通过我的应用程序将图像发布到用户墙上(他们在活动时走到摄像机前)。我的应用程序上周成功运行,现在它无法运行并报告“在等待未完成的响应时获得了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);     
    }

1 个答案:

答案 0 :(得分:0)

返回的错误消息与问题不符。

我修正了这个错误,因为我试图上传照片但没有传递正确的文件路径。