Feed Dialog posts not showing on the news feed - facebook

I'm using Feed Dialog to create a post from my website's micro app onto a user's facebook wall/feed. However, whenever I make the post from my website, the post shows up on my wall, but never in the news feed. I have checked & confirmed with friends, and my own account. The posts, while visible on my wall, do not appear in the news feed at all. None of these friends are blocked or have blocked my posts, which I have confirmed by going over there settings with them in person, some of these friends are in fact family which have full access to all my profile elements. For whatever reason the posts aren't showing up. I scoured google and found only two questions that matched mine exactly with no answers. The comments I know are off, they are just for me and I understand them, my site's urls and app codes are removed.
The posts work, except they never appear on the feed. Can anyone explain this, what am I doing wrong?
THANKS :D
Here is the code for the postToFeed function
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US /all.js'></script>
<!--<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>-->
<p id='msg'></p>
<!-- REQUIRED -->
<script>FB.init({appId: "SECRET", status: true, cookie: true, xfbml: true});
//This is the functional trigger for Feed Dialogue using FB.ui
function postToFeed() {
// vars pull the data from the form based on the id's of each input element
var linkStr = document.getElementById('link').value;
var nameStr = document.getElementById('mname').value;
var descStr1 = document.getElementById('hr').value;
var descStr2 = document.getElementById('life').value;
var descStr3 = document.getElementById('party').value;
var descStr4 = document.getElementById('weap').value;
var descStr5 = document.getElementById('click').value;
var descStr6 = document.getElementById('ttier').value;
var descStr7 = document.getElementById('mn').value;
// Determine if the monster is critical based on the hours variable
if (descStr1 < "25") {
var critStr = "CRITICAL"
var pic = "(my site URL"
}
else {
var critStr = ""
var pic = "(mysite URL)"
}
// Build the post using variable data pulled from form
var obj = {
method: 'feed',
link: linkStr,
picture: pic,
name: nameStr + ' ' + critStr,
description: 'Time Left:' + descStr1 + ':' + descStr7 + 'Hrs | Top Tier Full?: ' + descStr6 + ' | Life Left:' + descStr2 + '% | Party/Defence:' + descStr3 + '% | # of Weapons Launched: ' + descStr4 + ' | Clicks for next: ' + descStr5
};
// Check if posted
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>

Related

Image uploaded from Mobile phone to Angular is sideways or upside down

I am able to upload images from my desktop to an Angular based Web Application overlayed on SharePoint without issue, but if I upload from a Mobile phone, such as an iPhone, using the take "Take Photo or Video" or "Photo Library" function, it causes the image to be sideways when taken in portrait or upside down when taken in landscape. Here is my current upload function. Any clues/have others had the same issues uploading to Mobile Web Applications from iPhones/Mobile Phones to a SharePoint library?
Here is my upload function:
// Upload of images
$scope.upload = function () {
//console.log($scope.files);
if (document.getElementById("file").files.length === 0) {
alert('No file was selected');
return;
}
var parts = document.getElementById("file").value.split("\\");
var uploadedfilename = parts[parts.length - 1];
var basefilename = uploadedfilename.split(".")[0];
var fileextension = uploadedfilename.split(".")[1];
var currentdate = new Date();
var formatteddate = $filter('date')(new Date(currentdate), 'MMddyy-hmmssa');
var filename = basefilename + formatteddate + '.' + fileextension;
var file = document.getElementById("file").files[0];
uploadFileSync("/sites/asite", "Images", filename, file);
}
//Upload file synchronously
function uploadFileSync(spWebUrl, library, filename, file)
{
console.log(filename);
var reader = new FileReader();
reader.onloadend = function(evt)
{
if (evt.target.readyState == FileReader.DONE)
{
var buffer = evt.target.result;
var completeUrl = spWebUrl
+ "/_api/web/lists/getByTitle('"+ library +"')"
+ "/RootFolder/Files/add(url='"+ filename +"',overwrite='true')?"
+ "#TargetLibrary='"+library+"'&#TargetFileName='"+ filename +"'";
$.ajax({
url: completeUrl,
type: "POST",
data: buffer,
async: false,
processData: false,
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-length": buffer.byteLength
},
complete: function (data) {
console.log(data);
},
error: function (err) {
alert('failed');
}
});
}
};
reader.readAsArrayBuffer(file);
}
The output of these is just pushed into an array for use in an Angular UI Carousel:
// Control of Image Carousel
$scope.myInterval = 0;
// Population of carousel
$scope.slides = [];
appImages.query({
$select: 'FileLeafRef,ID,Created,Title,UniqueId',
$filter: 'ReportId eq ' + $routeParams.Id + ' and DisplayinReport eq 1',
}, function (getimageinfo) {
// Data is within an object of "value"
var image = getimageinfo.value;
// Iterate over item and get ID
angular.forEach(image, function (imagevalue, imagekey) {
$scope.slides.push({
image: '/sites/asite/Images/' + imagevalue.FileLeafRef,
});
});
});
The image carousel is on page as follows:
<div style="height: 305px; width: 300px">
<carousel interval="myInterval">
<slide ng-repeat="slide in slides" active="slide.active">
<img ng-src="{{slide.image}}" style="margin:auto;height:300px">
<div class="carousel-caption">
<h4>Slide {{$index}}</h4>
<p>{{slide.text}}</p>
</div>
</slide>
</carousel>
</div>
IMPORTANT: The images are sideways and upside down upon upload to the SharePoint library, so irrespective of outputting them, they seem to be misoriented when they hit the destination library I am using as a source to display on page.
How do I upload the images so SharePoint respects the EXIF data/orientation?
It may be related to EXIF. See JS Client-Side Exif Orientation: Rotate and Mirror JPEG Images
If you want a better answer, we will need the code which show the image, and the code server side.
UPDATE : I'm not an expert at all on SharePoint, but you can found a lot about it in the SharePoint Stack Exchange. For example, https://sharepoint.stackexchange.com/questions/131552/sharepoint-rotating-pictures-in-library, should do the trick.
To sum up a little : in your case, their could be a lot of cases to study. So, I recommended you auto-correct the exif, and then permit to your user to correct it if the auto-correct was wrong. Their is a lot of tools to do that. If you want to do it server-side, look at the link above, and if you want to do it on the client side, you could use JS-Load-Image for example.

Displaying facebook feed using FB.api

I want a to display my facebook feed in my site that show only specific #hashtag, for example "#StarComm". This is my code.
var page_id = 'MY APP ID';
var pageaccessToken='MY Token';
FB.api('/' + page_id + '/feed?q=%23StarComm&access_token='+ pageaccessToken, {limit:5} , function(response){
if (response && response.data && response.data.length){
var ul = document.getElementById('pagefeed');
for (var j=0; j<response.data.length; j++){
var feed = response.data[j],
li = document.createElement('li'),
a = document.createElement('a');
a.innerHTML = feed.message;
a.href = feed.link;
li.appendChild(a);
ul.appendChild(li);
}
}
});
My out put is like this.
Follow us on twitter at https://twitter.com/StarcommOnline #StarComm
And i want my output is like the standard fb:like-box. Thanks in Advance!

jQuery Autocomplete id and item

I have a working query autocomplete code that completes the full_name when letters are typing. What I am trying to figure out is how to get the user_id for that goes with the full_name. I have JSON that comes back like so:
[{"full_name":"Matt","user_id":"2"},{"full_name":"Jack","user_id":"9"},{"full_name":"Ace","user_id":"10"},{"full_name":"tempaccount","user_id":"11"},{"full_name":"Garrett","user_id":"26"},{"full_name":"Joe","user_id":"29"},{"full_name":"Raptors","user_id":"32"}]
Below is my jQuery code. I am using PHPfox framework.
$(function(){
//attach autocomplete
$("#to").autocomplete({
//define callback to format results
source: function(req, add){
//pass request to server
//$.getJSON("friends.php?callback=?", req, function(data) {
$.ajaxCall('phpfoxsamplee.auto', 'startsWith='+req.term)
.done(function( data ) {
//create array for response objects
var suggestions = [];
var data = $.parseJSON(data);
//process response
$.each(data, function(i, val){
//suggestions.push(val.full_name,val.user_id); (This works and shows both the full name and id in the dropdown. I want the name to be visible and the ID to goto a hidden input field)
suggestions.push({
id: val.user_id,
name: val.full_name
});
});
//pass array to callback
add(suggestions);
});
},
//define select handler
select: function(e, ui) {
//create formatted friend
alert(ui.item.full_name); //Trying to view the full_name (doesn't work)
alert(ui.item.id); // trying to view the id (doesn't work)
var friend = ui.item.full_name, (doesn't work)
//var friend = ui.item.value, (This works if I do not try to push labels with values)
span = $("<span>").text(friend),
a = $("<a>").addClass("remove").attr({
href: "javascript:",
title: "Remove " + friend
}).text("x").appendTo(span);
//add friend to friend div
span.insertBefore("#to");
$("#to").attr("disabled",true);
$("#to").attr('name','test').attr('value', 'yes');
$("#to").hide();
},
//define select handler
change: function() {
//prevent 'to' field being updated and correct position
$("#to").val("").css("top", 2);
}
});
//add click handler to friends div
$("#friends").click(function(){
//focus 'to' field
$("#to").focus();
});
//add live handler for clicks on remove links
$(".remove", document.getElementById("friends")).live("click", function(){
//remove current friend
$(this).parent().remove();
$("#to").removeAttr("disabled");
$("#to").show();
//correct 'to' field position
if($("#friends span").length === 0) {
$("#to").css("top", 0);
}
});
});
HTML
<div id=friends class=ui-help-clearfix>
<input id='to' type=text name='player[" . $num . "][name]'></input>
</div>
Consider the JQuery Autocomplete Combobox. It is not a standard widget, but you can pretty much paste their source. And it will enable you to capture values corresponding to text selections.

Json parse from Facebook events

I have had some trouble with fetching json from a groups events on facebook and then put them in a tableview to be used in a Appcelerator mobile app.
The idea is to have this as a calendar to show events for a club in a simple way.
I want to show the name of the event. The picture for that event and the date for the event.
All in a tablerow.
I have gotten to the part where i can get the Name and date for the events with this code:
Ti.UI.backgroundColor = '#dddddd';
var access_token='AAACEdEose0cBAAICGa4tFTcZAqCOGm2w9qPYGZBwNtJ1oZAcwaMAP2DDHZCN58cvVBZCHZADZAZBTPC8tTnpfQ7uGKI5j3SbMYcRmWquZCdPzhwZDZD';
var url = "https://graph.facebook.com/64306617564/events?&access_token=" + access_token ;
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
var tableData = [];
var json, data, row, name, start_time, id;
var xhr = Ti.Network.createHTTPClient({
onload: function() {
// Ti.API.debug(this.responseText);
json = JSON.parse(this.responseText);
for (i = 0; i < json.data.length; i++) {
data = json.data[i];
row = Ti.UI.createTableViewRow({
height:'60dp'
});
var name = Ti.UI.createLabel({
text:data.name,
font:{
fontSize:'18dp',
fontWeight:'bold'
},
height:'auto',
left:'50dp',
top:'5dp',
color:'#000',
touchEnabled:true
});
var start_time = Ti.UI.createLabel({
text:'"' + data.start_time + '"',
font:{
fontSize:'13dp'
},
height:'auto',
left:'15dp',
bottom:'5dp',
color:'#000',
touchEnabled:true
});
row.add(name);
row.add(start_time);
tableData.push(row);
}
table.setData(tableData);
},
onerror: function(e) {
Ti.API.debug("STATUS: " + this.status);
Ti.API.debug("TEXT: " + this.responseText);
Ti.API.debug("ERROR: " + e.error);
alert('There was an error retrieving the remote data. Try again.');
},
timeout:5000
});
xhr.open("GET", url);
xhr.send();
But when i want the specific event to open in a new window when clicked i just get the event that lies last on the screen when i put this in a browser:
https://graph.facebook.com/64306617564/events?&access_token=AAACEdEose0cBAOLAFWMKPmvgqEwap1ldnl7DeZBDKJC6YTZC4Goh6K5NHsvpOFmFQaGp1IekVsCxZCZCz3lwGpRcQG9ZBkcMrZAnLk4As8kgZDZD
And the access token expires REALLY fast. Any ideas how to make an access token that lasts longer?
Well, the code i am using to open the window is:
table.addEventListener('click',function(e) {
// Create the new window with the link from the post
var blogWindow = Ti.UI.createWindow({
title : data.name,
modal : true,
barColor: '#050505',
backgroundColor: '#050505'
});
var webView = Ti.UI.createWebView({url:'http://www.facebook.com/events/' + data.id});
blogWindow.add(webView);
// Create the close button to go in the left area of the navbar popup
var close = Titanium.UI.createButton({
title: 'Close',
style: Titanium.UI.iPhone.SystemButtonStyle.PLAIN
});
blogWindow.setLeftNavButton(close);
// Handle the close event
close.addEventListener('click',function() {
blogWindow.close();
});
blogWindow.open();
});
win.add(table);
win.open();
in my opinion that should open the event that is clicked on by parsing the ID from the row and putting it after the link.
Am i retarded or what is wrong?
It doesnt matter on which event i click it just open the last one all of the times.
And how can i get a thumbnail for the events?
Pls help........
When you click on table to get value from data which is not available.You can achieve it using you custom variable try to put this line of code at your row creation where you add your row in array i.e.row.data = data; and on table click event get that object using this alert(e.source.data); and check it. Best luck

appcelerator titanium mobile Facebook login - alway have not set Titanium.Facebook.loggedIn after login

My mobile app will first require user to login facebook and then go back to the app for further action.
After login fb successfully, it is expected that the Titanium.Facebook.loggedIn will be true and the app can get the value in Ti.Facebook.uid.
However, it is not always the case. Sometimes, after login fb successfully and go back to the app, the Titanium.Facebook.loggedIn is still false and sure cannot get the Ti.Facebook.uid.
But when the user logout and login again within the same app section, it will work fine. Therefore, my app sometimes requires users to login facebook twice.
Do u have any idea of it? The code is listed below.
var login = Titanium.Facebook.createLoginButton({
top: 100, style:'wide'
});
var actionsView = Ti.UI.createView({
top: 0, left: 0, right: 0, touchEnabled: false, height: 320
});
var loginView = Ti.UI.createView({
top: 0, left: 0, right: 0, visible: !Titanium.Facebook.loggedIn, height: Titanium.Platform.displayCaps.platformHeight,opacity:0.85, backgroundColor:'#fff'
});
loginView.add(login);
Titanium.Facebook.addEventListener('login', function(e) {
if (e.success) {
if (Titanium.Facebook.loggedIn){
loginView.hide();
actionsView.touchEnabled=true;
}else{
statusAlert = Titanium.UI.createAlertDialog({title:appname,message:'Login failed.'});
statusAlert.show();
}
if (e.error) {
alert(e.error);
}
});
var logout = Titanium.Facebook.createLoginButton({
top: 300, style:'wide', visible: false
});
You could use Titanium.Facebook.uid instead, that would be something like:
if (Titanium.Facebook.uid){
But probably the problem you are having is due an old Titanium version.
After successful login via facebook save user id into a global variable or in app properties.
I will prefer app properties because unless the user will logout from facebook the uid will remain in the app properties
i-e
Ti.App.Properties.setString('uid', Ti.Facebook.uid);
so when you use your app back just check the uid first.
var fb_id = Ti.App.Properties.getString('uid');
if(fb_id){
// your code
}
and when you logout clear the variable with '' or null.
May be a bit late for an additional answer, but I had a similar problem on iOS. Logging in via FB worked great but after closing the app completely the Facebook module returned 'undefined' when asked for the UID. I solved it by calling the undocumented 'initialize' method.
Follow the setup guide here: https://docs.appcelerator.com/platform/latest/#!/api/Modules.Facebook
And then try this example
var fb = require('facebook');
fb.addEventListener('login', function(e) {
if (e.success) {
alert('login from uid: ' + e.uid + ', name: ' + JSON.parse(e.data).name);
showFriends();
} else if (e.cancelled) {
// user cancelled
alert('cancelled');
} else {
alert(e.error);
}
});
fb.initialize();
function authorize(e) {
fb.authorize();
}
function showFriends() {
alert("fb:\n" + fb.uid + "\n" + fb.accessToken + "\n" + fb.expirationDate);
fb.requestWithGraphPath('me/friends', {
limit : 1000,
}, 'GET', function(e) {
if (e.success) {
// Note: only friends who installed this app are returned
var result = JSON.parse(e.result);
alert("successfully loaded friends");
// each data (user) has id + name fields
} else if (e.error) {
alert('fb friends: ' + e.error);
} else {
alert('Unknown response');
}
});
}
if (fb.loggedIn) {
$.button.hide();
alert("already logged in");
} else {
$.button.show();
}
$.index.open();
Of course you would need something like
<Button id="button" onClick="authorize" >log in</Button>
in your view.