2013-09-24 2 views
-1

현재 PHP (Codeigniter)로 스크립트를 실행 한 후 내 페이스 북 페이지에 URL/상태를 게시하려고합니다. 현재 다음과 같은 오류가 발생했습니다 uncaught oauthexception invalid oauth access token signature. 문제는 내 액세스 토큰이 잘못되었지만 Facebook에서 읽은 문서가 아무리 많아도 알 수없는 사실을 알고 있습니다. 누군가가 내게 액세스 토큰을 얻는 방법에 대한 해결책을 줄 수 있습니까?Facebook 액세스 토큰을 가져올 수 없습니까?

 include('system/libraries/facebook.php'); 

    if($this->session->userdata('level') == "admin"){ 

     $role = $this->input->post('role'); 
     $company = $this->input->post('company'); 
     $location = str_replace('+', ' ', $this->input->post('location')); 
     $category = str_replace('+', ' ', $this->input->post('category')); 
     $type = str_replace('+', ' ', $this->input->post('type')); 
     $description = $this->input->post('description'); 
     $extract = $this->input->post('extract');   
     $date = time(); 
     $link = $this->input->post('link'); 

     if($this->input->post('closing_date')){ 
      $closing_date = $this->input->post('closing_date'); 
      $closing_date = str_replace('/', '-', $closing_date); 
      $closing_date = strtotime($closing_date); 
     }else{ 
      $closing_date = time() + 2592000; 
     } 

     $url = str_replace(' ', '-', trim($role)); 
     $location_dash = str_replace(' ', '-', trim($location)); 
     $url = $url."-in-".$location_dash; 

     $this->db->set('role', $role); 
     $this->db->set('company', $company); 
     $this->db->set('type', $type); 
     $this->db->set('location', $location); 
     $this->db->set('category', $category); 
     $this->db->set('url', strtolower($url));    
     $this->db->set('description', $description); 
     $this->db->set('extract', $extract);    
     $this->db->set('link', $link);   
     $this->db->set('time', $date); 
     $this->db->set('closing_date', $closing_date); 
     $this->db->set('active', 1); 

     $this->db->insert('jobs'); 

     $job = $this->db->get_where('jobs', array('time' => $date))->row_array(); 

     $url = "http://www.example.com/job/view/".$job['id']."/".$job['url'].""; 

     $facebook = new Facebook(array(
      'appId' => '***', 
      'secret' => '***' 
     )); 

     $message = array(
     'access_token' => "***", 
     'message'=> "".$url."" 
     ); 

     $facebook->api('/me/accounts','POST', $message);    
+0

_ "문제는 내 액세스 토큰이 잘못되었다는 것을 알고 있습니다."_ 그래서 관심없는 코드가 길면 좋을 것이라고 생각 했으므로 _except_ 그 액세스 토큰을 받고 ...? – CBroe

+0

@CBroe 현재 https://developers.facebook.com/tools/explorer/?method=GET&path=me/accounts에서 내 access_token을 받고 있지만 올바른 액세스 코드가 있는지 확실하지 않습니다. – learn

+0

그래프 API 탐색기에서 자신의 응용 프로그램을 사용하는 토큰 (상단의 드롭 다운에서 선택). 그렇지 않으면 GAE 응용 프로그램 용이므로 app_id/app_secret와 일치하지 않습니다. – CBroe

답변

1

웹 사이트에서 Facebook으로 어떻게 로그인 했습니까? 성공적으로

를 게시해야

$message = array(
    'access_token' => $facebook->getAccessToken(), // Get current access_token 
    'message'=> "".$url."" 
); 

$facebook->api('/me/accounts','POST', $message); 

그리고 : 당신은 당신이 사용하고 있는지 확인해야합니다

$loginUrl = $facebook->getLoginUrl(array('scope' => 'publish_actions')); 

publish_actions 범위는 응용 프로그램이

그런 다음 사용하는 사용자를 대신하여 게시물을 만들 수 있습니다 희망은 그 문제를 해결합니다!

관련 문제