0

我有了這個代碼來處理Facebook的迴應:處理Facebook的響應

if (response && !response.error_message) { 
          alert('Posting completed with Post ID:' + response.post_id); 
          FB.api('/' + response.post_id, function(response) { 
           x$().xhr('<?php echo Yii::app()->createUrl('survey/saveSocialMediaPost', array('answer_id'=>$answer->id, 'social_network'=>1)); ?>', { 
            method: 'POST', 
            async: true, 
            meta: response, 
           }); 
           console.log(response); 
          }); 
         } else { 
          alert('Error while posting.'); 
         } 
        } 

正如你所看到的,一個右門柱就是我想要做的是後調用AJAX做一些動作在我的數據庫。這裏的問題是我不知道如何處理響應。執行console.log(響應)拋出這樣的事情:

Object { created_time: "2016-03-05T01:27:27+0000", message: "Prueba de comentarios.", id: "xxxxxx_xxxxx" } 

正是我需要得到的是message。 id用response.post_id解決。

+0

你想實現什麼,以及想要從響應保存到DB? – Farside

回答

0

如何:

console.log(response.message); 

It's一個簡單的JSON對象,你應該熟悉JSON - it's在JavaScript世界非常重要。

+0

這正是我想要的。謝謝! –

+0

不客氣。請不要忘記接受我的回答:) – luschn