2011-03-07 5 views
2

처리 애플릿을 통해 Facebook 사용자의 벽면에 무언가를 게시하고 싶습니다. 먼저 oauth 인증을 통해 app_id와 user_id를 가진 사용자의 access_token을 얻습니다. 나는 이것을 code 고마워요, 호르헤http post facebook graph api processing

지금은 벽에 게시하고 싶습니다. 나는, "XXX를"; "access_token은"이 인수 https://graph.facebook.com/USER_ID/feed 에 HTTP POST 요청을! 메시지 ","... 처리 확인 "

요청의 응답이

executing request: POST https://graph.facebook.com/USER_ID/feed HTTP/1.1 
---------------------------------------- 
HTTP/1.1 403 Forbidden 
---------------------------------------- 
{"error":{"type":"OAuthException","message":"(#200) This API call requires a valid app_id."}} 

무엇인지 그 의미 하는가? 을 내가 유효한 APP_ID를 입력 ... 그렇지 않으면 내가 access_token이를하지 않았다?

관련, 피터

import org.apache.http.HttpEntity; 
import org.apache.http.HttpResponse; 
import org.apache.http.client.methods.HttpPost; 
import org.apache.http.impl.client.DefaultHttpClient; 

void setup() 
{ 
    String url = "https://graph.facebook.com/USER_ID/feed"; 

    try 
    { 
    DefaultHttpClient httpClient = new DefaultHttpClient(); 

    HttpPost   httpPost = new HttpPost(url); 
    HttpParams  postParams = new BasicHttpParams(); 
         postParams.setParameter("access_token", "XXX"); 
         postParams.setParameter("message", "Check ... Processing!"); 
         httpPost.setParams(postParams);  

    println("executing request: " + httpPost.getRequestLine()); 

    HttpResponse response = httpClient.execute(httpPost); 
    HttpEntity entity = response.getEntity(); 


    println("----------------------------------------"); 
    println(response.getStatusLine()); 
    println("----------------------------------------"); 

    if(entity != null) entity.writeTo(System.out); 
    if(entity != null) entity.consumeContent(); 


    // When HttpClient instance is no longer needed, 
    // shut down the connection manager to ensure 
    // immediate deallocation of all system resources 
    httpClient.getConnectionManager().shutdown();  

    } catch(Exception e) { e.printStackTrace(); } 

    exit(); 
} 
+0

'publish_stream' 권한을 얻었습니까? 'access_token'을 쓸 필요가 없다면! – ifaour

+0

나는이 요청을했다 : http : //www.facebook.com/login.php?api_key=YOUR_API_KEY&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http : // www .facebook.com/connect/login_failure.html & fbconnect = true & return_session = true & req_perms = read_stream, publish_stream, offline_access하지만 http 게시 요청이 작동하지 않습니다. –

+0

http : // 사이에 공백이 있으면 죄송합니다. 그렇지 않으면 링크가 올바르게 표시되지 않습니다. –

답변

0

글자 그대로 'USER_ID'가 아닌 요청 URL에 사용자 ID를 포함해야합니다. litereally 바로 가기를 사용

String url = "https://graph.facebook.com/"+user_id+"/feed"; 

또는 :

그래서 당신도 할 수있는 페이스 북이 '나'

의 leiu에 액세스 토큰의 사용자 ID에 보이는

String url = "https://graph.facebook.com/me/feed";