HD

페이스북 SNS data 뿌리기 본문

javascript/페이스북 SNS

페이스북 SNS data 뿌리기

hunecenter 2019. 7. 29. 11:05
반응형

 

<%@page import="java.net.HttpURLConnection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.net.URL, org.jdom.Document, org.jdom.Element, org.jdom.input.SAXBuilder, org.xml.sax.InputSource, java.util.List, java.text.SimpleDateFormat, java.util.Date, java.util.Locale, java.text.ParseException  "%>
<%@ page import="java.net.URLConnection, java.io.InputStream, java.io.InputStreamReader, java.io.BufferedReader, java.io.File" %>

<%
List facebookList = null;

SimpleDateFormat oldFormat = new SimpleDateFormat("EEE, dd MMM yy", Locale.ENGLISH);
SimpleDateFormat oldFormat2 = new SimpleDateFormat("dd MMM yy", Locale.ENGLISH);
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
Date parsedDate = null;
URL url = null;

%>

//facebook
	$(document).ready(function() {
		var tocken = "액세스 토큰 값 넣으시면 됩니다.";
		$.ajax({
			type: "GET",
			dataType: "jsonp",
			cache: false,
			url : "https://graph.facebook.com/v3.3/me?fields=posts.limit(8)%7Bfull_picture%2Cmessage%2Ccreated_time%2Cpermalink_url%7D&access_token="+tocken,
			success: function(response) {
				if(response.posts.data.length > 0){
					for(var i = 0; i < response.posts.data.length; i++){
						var facebook = '<li>';
						facebook += "<a target='_blank' href='" + response.posts.data[i].permalink_url + "' title='새창 열기'>";
						facebook += "<div class='snsSum'>";
						facebook += '<p class="sns_content">'+response.posts.data[i].message+'<span>';
						facebook += "<p class='sns_date'>";
						facebook +=  response.posts.data[i].created_time.substr(0,10);
						facebook += "</p>";
						facebook += "</div>";
						facebook += '<img src="' + response.posts.data[i].full_picture + '" alt="페이스북_'+i+'">';
						facebook += "</a>";
						facebook += "</li>";
						$("#facebookUl").append(facebook); //해당 append 해줄 id 또는 class wlwjd
					}
				}
			}
		});
	});
	
    
 <!--facebook-->
<ul id="facebookUl">
	//여기에 <li>로 내용들이 그려지게 됩니다.
</ul>

 

 

반응형
Comments