Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
谷歌+;还有facebook api/rss提要,比如twitter api提要_Facebook_Feed_Google Plus - Fatal编程技术网

谷歌+;还有facebook api/rss提要,比如twitter api提要

谷歌+;还有facebook api/rss提要,比如twitter api提要,facebook,feed,google-plus,Facebook,Feed,Google Plus,我搜索了很多,在StackOverflow中也看到了一些和我一样的问题,但没有得到答案 我需要获取用户(google+和facebook)在他/她的帐户下发布的任何消息,并将其作为xml响应发送给移动应用程序,该应用程序将以更好的格式/设计显示用户帖子-因此,这里我需要使用配置文件id/用户名从google+/facebook获取帖子 比如说,我可以从推特上看到他们的状态 有没有什么图书馆或什么特别的方法可以让我得到它 提前感谢。我只能与Facebook和Twitter通话,因为它们是我使用过

我搜索了很多,在StackOverflow中也看到了一些和我一样的问题,但没有得到答案

我需要获取用户(google+和facebook)在他/她的帐户下发布的任何消息,并将其作为xml响应发送给移动应用程序,该应用程序将以更好的格式/设计显示用户帖子-因此,这里我需要使用配置文件id/用户名从google+/facebook获取帖子

比如说,我可以从推特上看到他们的状态

有没有什么图书馆或什么特别的方法可以让我得到它


提前感谢。

我只能与Facebook和Twitter通话,因为它们是我使用过的唯一两种社交媒体API

这两个API都是RESTful服务。对于Twitter和Facebook,您需要在透视平台上创建应用程序,以便为您的应用程序获取令牌,该令牌将通过RESTful服务获取数据

对于FaceBook,您可以利用此功能进行开发。这使您无需在FaceBook平台上创建应用程序即可进行开发

FaceBook和Twitter都有社区驱动的项目,用于以各种语言访问这些web服务。因为您是为Android做这件事的,所以我假设您希望您的程序能够用Java获取这些数据

是我推荐的Java FaceBook库

FacebookClient facebookClient = new DefaultFacebookClient(authToken);
User facebookUser = facebookClient.fetchObject("me", User.class);
是一个很棒的Java Twitter库

因为,核心概念是一个很好的起点。
有关Twitter的更多信息,请参见

,您可以使用Google+的活动API。这是目前仅限于公共职位,但应该足以让你开始。配置文件ID来自用户的配置文件。您还可以通过其他方式获取此内容,包括搜索API

各种语言的文档和简单示例可以在Google plus页面上找到(https://developers.google.com/+/api/latest/activities)和以下JavaScript示例可能有助于查看事物的工作方式:

// globals used for auth, showing debugging
var debug = true;
var key   = "your api key from https://code.google.com/apis/console";


function handleRequestIssue(request){
    // For now, just show the error
    console.log("Error, status:" + request.status + " /  response:" + request.responseText);
}

function performXHR(URL){
  var objReturn = "";      
  var request = new XMLHttpRequest();
  request.open('GET', URL, false);
  request.send(); // because of "false" above, will block until the request is done 
                  // and status is available. Not recommended, however it works for simple cases.

  if (request.status === 200) {
    if (debug) console.log(request.responseText);
    var objReturn = jQuery.parseJSON(request.responseText).items;

    if (debug){
      for (value in objReturn){
        console.log(value);
      }
    } 
  }else{
    handleRequestIssue(request);
  }
  return objReturn;
}

// Gets the activities for a profile
function getActivities(profileID){
  var activities = null;      
  var URL        = "https://www.googleapis.com/plus/v1/people/" + profileID + "/activities/public?alt=json&key=" + key;
  activities     = performXHR(URL);
  console.log(activities.length);
  return activities;
}
此时,您可以在调试器中看到活动。您始终可以在div或其他内容中将内容呈现为HTML

function renderActsComments(activities, identifier, filter){
    var renderMe = "";
    console.log("activities retrieved: " + activities.length);

    for (var i=0; i < activities.length; i++) {
      var render = true;
      console.log("trying to do something with an activity: " + i);
      var activity = activities[i];
      if (filter != null && filter.length > 0){
        if (activity.crosspostSource.indexOf(filter) == -1){
          render = false;
        }
      }


      if (render == true){
        renderMe += "<br/><div class=\"article\"><p>" + activity.title + "</p>";
        console.log(activity.id);

        // get comments
        var comments = getCommentsForActivity(activity.id);
        var left = true;
        for (var j=0; j<comments.length; j++){
          if (left){
            left = false;
            renderMe += "<br/><p class=\"speech\">" + comments[j].object.content + "</p>";
            renderMe += "<a href=\"" + comments[j].actor.url + "\">" + comments[j].actor.displayName + "</a>";
            renderMe += "<a href=\"" + comments[j].actor.image.url.replace(/\?.*/, "") + "\">";
            renderMe += " <img border=0 src=\"" + comments[j].actor.image.url + "\"/></a>";
            renderMe += "</p>";
          }else{
            renderMe += "<br/><p class=\"speechAlt\">" + comments[j].object.content + "</p>";
            left = true;
            renderMe += "<p class=\"profileAlt\">";
            renderMe += "<a href=\"" + comments[j].actor.image.url.replace(/\?.*/, "") + "\">";
            renderMe += "<img border=0 src=\"" + comments[j].actor.image.url + "\"/></a>";
            renderMe += "<a href=\"" + comments[j].actor.url + "\"> " + comments[j].actor.displayName + "</a>";
            renderMe += "</p>";
          }
        }
        renderMe += "</div>";
      }
    }
    console.log("I'm done");

    document.getElementById(identifier).innerHTML = renderMe;
    return renderMe;
}
函数呈现建议(活动、标识符、筛选器){
var renderMe=“”;
日志(“检索到的活动:+activities.length”);
对于(变量i=0;i0){
if(activity.crosspostSource.indexOf(filter)=-1){
render=false;
}
}
if(render==true){
renderMe+=“
”+activity.title+“

”; console.log(activity.id); //获得评论 var comments=getCommentsActivity(activity.id); var left=真;
对于(var j=0;j有足够的库来解析和使用twitter状态,但不能与fb/google+一起使用(这似乎太难了),我将在fb中挖掘更多内容,以获取应用程序上的提要列表。