I need all the profile pictures of square size. Presently I am able to loop through all the profile pictures but I am unable to get each of those pictures of same size. Since I have a unique id for each picture is there anyway to get that picture with a definite size?
Here is the code
FB.api('/me/albums', {access_token: token},function(resp) {
for (var i=0, l=resp.data.length; i<l; i++){
var album = resp.data[i];
if(album.name=="Profile Pictures"){
FB.api(album.id + "/photos", function(response) {
for(var j=0;j<response.data.length;j++){
$("#container").append("<li><input type='radio' class='fbimg'><img src='" + response.data[j].picture + "' /></input></li>");
}
});
}
}
});
Related
I am making an application based on ionic-1 where I need to take access camera as well as gallery. I used Cordova Camera plugins. It is working properly. Using this plugin we can access not only our device gallery but also our drive, documents etc. But main problem is, I cant select multiple image from gallery. I need to select it one by one.
How may I solve this issue..? I do not want to use cordova image picker plugins.
You can solve this issue by using cordova-imagePicker plugin. you can access it from github.
The plugin creates the object window.imagePicker with the method
getPictures(success, fail, options).
with this plugin you can select multiple photos
window.imagePicker.getPictures(
function(results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
}
}, function (error) {
console.log('Error: ' + error);
} ); Example - Get at most 10 images scaled to width of 800:
window.imagePicker.getPictures(
function(results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
}
}, function (error) {
console.log('Error: ' + error);
}, {
maximumImagesCount: 10,
width: 800
} );
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.
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!
I'm trying to show the cover photos of a Facebook user's albums, but I am not having any luck.
What I have so far is this:
FB.api('/me/albums', function(response) {
for(var i = 0; i < response.data.length; i++)
{
if(response.data[i].cover_photo != undefined)
{
var alb = $('<div class="album" id="album-' + response.data[i].cover_photo + '"></div>').appendTo(view_scroll);
alb.css('background', 'url(https://graph.facebook.com/' + response.data[i].cover_photo + '/picture)');
}
}
});
All I am getting is a question mark image. Any suggestions on how get the actual cover image into the background of the div?
Found it... Needed to add the access token to the end of the url:
background-image: url(https://graph.facebook.com/' + response.data[i].cover_photo + '/picture?access_token=' + [ACCESSTOKEN]
Hi i had the same problem, and i already got the cover_photo from every album of the user. Im using javascript sdk. After checking the login status, just call the function albumes():
function albumes() {
FB.api('/me/albums?fields=name,link,cover_photo,id',
function(response) {
for(var c = 0 ; c < response.data.length ; c++) {
coverPhoto(response.data[c].cover_photo, response.data[c].name);
}
}
);
}
function coverPhoto(id, nombre){
FB.api('/'+id+'?fields=picture',
function(responseIn) {
$('#javascriptData').append(
"<br>"+ nombre +"<img src='"+ responseIn['picture'] +"'>");
}
);
}
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>