2011-09-28 11 views
5

Przyjaciele, zamieściłem łącze audio do ściany znajomych Facebooka bez okna dialogowego. Mogę odtworzyć łącze Wysłane audio na Facebooku, ale nie mogę podać tytułu, nazwy. Skierować obrazka - Chcę, żeby móc dodawać jak What i expect ..Problem z nazwaniem pliku audio w Facebooku Post w Androidzie

What i am getting

Po to mój kod:

try{ 
String userID="1000021233268431111"; 
Bundle params = new Bundle(); 
params.putString("name", "name of link"); 
params.putString("title", "title of link"); 
params.putString("descrption", "descrption of link"); 
params.putString("caption", "Get utellit to send messages like this!"); 
params.putString("link", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3"); 
params.putString("type", "mp3"); 
params.putString("source", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3"); 
String response = facebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");  
Log.v("response", response); 
} catch(Exception e){ 
} 

jeśli staram się korzystać z tablicy JSON dodać załącznik, nic nie dodaje się w parametr i otrzymuję pusty słupek tak: enter image description here

Korzystanie JSON kod ARRAY MU:

Bundle parameters = new Bundle(); 
JSONObject attachment = new JSONObject(); 
try { 
    JSONObject media = new JSONObject(); 
    media.put("type", "mp3"); 
    media.put("src", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3"); 
    media.put("title", "Listen to your message"); 
    media.put("artist", "By: utellit for Android"); 
    media.put("album", "Utellit"); 
    attachment.put("media", new JSONArray().put(media)); 
} catch (JSONException e1) { 
    // TODO Auto-generated catch block 
    e1.printStackTrace(); 
} 
try { 
    attachment.put("message", "Messages"); 
    attachment.put("name", "Get utellit to send messages like this!"); 
    attachment.put("href", "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3"); 
} catch (JSONException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 
parameters.putString("attachment", attachment.toString()); 
String response =facebook.request(((userID == null) ? "me" : userID) + "/feed",parameters, "POST"); 
Log.v("response", response); 

Odpowiedz

7

Wreszcie mam go .. Oto moje rozwiązanie:

try{ 
String link="LINK that should goes if yoy click Get utellit to send messages like this"; 
String amazon_link=".mp3 link that should play inside Facebook"; 
Bundle parameters = new Bundle(); 
JSONObject attachment = new JSONObject(); 
try { 
    JSONObject media = new JSONObject(); 
    media.put("type", "mp3"); 
    media.put("src", amazon_link); 
    media.put("title", "Listen to your message"); 
    media.put("artist", "By: utellit for Android"); 
    media.put("album", "Utellit"); 
    attachment.put("media", new JSONArray().put(media)); 
} catch (JSONException e1) {} 

try { 
    attachment.put("message", "Messages"); 
    attachment.put("name", "Get utellit to send messages like this!"); 
    attachment.put("href", link); 
} catch (JSONException e) {} 
parameters.putString("attachment", attachment.toString()); 
parameters.putString("message", "Text is lame. Listen up:"); 
parameters.putString("target_id", "xxxx"); // target Id to post 
parameters.putString("method", "stream.publish"); 
String response = facebook.request(parameters);  
} 

catch (Exception e) {}

W facebook.request metody powinniśmy wysłać tylko parametry i metoda postu powinien być dodany w Załącznikach

Wreszcie mój post na Facebooku wygląda tak:

enter image description here

+0

+1 Thats Cool Man ... –

+0

Cześć Venky, czy to działa z najnowszym pakietem SDK Facebooka? Proszę zobaczyć moje pytania tutaj: http://stackoverflow.com/questions/18032973/posting-an-audio-mp3-file-through-feed-dialog-using-facebook-android-sdk Trochę twojej pomocy wymagany. –

Powiązane problemy