-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfbChat
More file actions
179 lines (130 loc) · 6.29 KB
/
fbChat
File metadata and controls
179 lines (130 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
(function(d, s, id)
{
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=1541311112808770}";
fjs.parentNode.insertBefore(js, fjs);
}
(document, 'script', 'facebook-jssdk')
);
FB.init({appId: "1474410539537569", status: true, cookie: false, oauth : true, xfbml : true});
});
function postToFeedbh()
{
//alert(document.getElementById('hidSelectedLink').value);
FB.api('/me/inbox', function(response)
{
// console.log(response);
/* $.each(response, function( i, value ) {
console.log(response.data[i].length);
});*/
console.log(response);
var records = response.data[0].to.data;
//var details = [];
$.each(records, function(i, record){
var name = record.name;
var id = record.id;
$.each(response.data, function(j, conversation){
//console.log(conversation.id);
//details[conversation.id] = [];
//var to = conversation.to;
var comments = conversation.comments.data;
$.each(comments, function(k, comment){
//console.log(j+" - "+k);
var commentFrom = "";
if(typeof comment.from != "undefined"){
commentFrom = comment.from.name
}
var message = comment.message;
document.getElementById("content").innerHTML += "comment from "+commentFrom+" message "+message+"<br><br><br>";
// console.log(" comment from "+commentFrom+" message "+message);
});
/*
$.each(conversation, function(prop, val){
details[]
})*/
})
//console.log(name+" - "+id);
})
//for(var i = 0; i < response.data.length; i++) {
//console.log(response.data[i].comments);
// for(var j = 0; j<)
// console.log(response.data[i].comments.data[i].from);
// console.log(response.data[i].comments.data[i].from.name);
//}
console.log(response);
// console.log(response.data);
var facebookid = response.id;
if(response.first_name)
{
alert("a");
document.getElementById('fbFirstName').value=response.first_name;
document.getElementById('fbLastName').value=response.last_name;
document.getElementById('fbpimage').value=response.picture.data.url;
document.getElementById('fbUserFullName').value=response.first_name+' '+response.last_name;
document.getElementById('fbEmail').value=response.email;
document.getElementById('user_form_email').value=response.id;
//document.newform.submit();
}
var userpass = response.first_name+response.last_name;
var facebookid = response.id;
var imgurl = "https://graph.facebook.com/"+facebookid+"/picture?width=230&height=230";// "https://graph.facebook.com/"+facebookid+"/picture?type=large"; //response.picture.data.url;
$('#user_form_plainPassword_password').val(userpass);
$('#user_form_plainPassword_conf_password').val(userpass);
$('#user_form_avatar').val(imgurl);
$('#facebook_name').html(response.first_name+' '+response.last_name);
$('#facebook_img').html('<img style="margin:0px" id="avatar_img" src="'+imgurl+'">');
$('#facebook_img_section').show();
// checkfacebookuser(facebookid);
});
}
function fblogin()
{
//alert("as");
FB.login(function(response)
{
postToFeedbh();
},
{scope:'email,read_stream,publish_actions,read_mailbox'});
}
</script>
<script src='https://connect.facebook.net/en_US/all.js'></script>
</head>
<body>
<div itemscope itemtype="http://schema.org/Product" itemref="_url2 _brand3" class="main"> <!-- search by state -->
<!-- write review -->
<div class="titles oranges border">
<h2>Reviewer Login</h2>
</div>
<!-- 12-23-2014 updates by grace starts-->
<style>
.fb_btn{width:100%;max-width:234px;float:right;}
@media only screen and (max-width: 768px) {.fb_btn{ float:none;margin:0 auto; } .fb{width: 68%;margin: 0 auto;float: none;}}
</style>
<!-- 12-23-2014 updates by grace ends-->
<form method="POST" class="signin" name="newform">
<div class="fb">
<a class="sn-button fb-login" href="#" onclick="fblogin();return false;">
<input class="fb_btn" type="image" value="a" style="/*width:20%; margin:0 0 0 80%;*/"> <!-- 12-23-2014 updates by grace -->
</a>
</div>
</div>
<br/>
<input type="hidden" name="fbUserFullName" id="fbUserFullName" style="border:none;background:white; color:#64829c;" readonly>
<input type="hidden" name="fbEmail" id="fbEmail" style="display:none;border:none;background:white; color:#64829c;" readonly>
<input type="hidden" name="fbFirstName" id="fbFirstName">
<input type="hidden" name="fbLastName" id="fbLastName">
<input type="hidden" name="fbpimage" id="fbpimage">
<input type="hidden" name="user_form_email" id="user_form_email">
<div id ="content"></div>
</div>
</div>
</form>
</body>