Note that there are some explanatory texts on larger screens.

plurals
  1. POTechnical issues when retrieving images using Facebook API call due to the randomized changes in Facebook domain and IP
    primarykey
    data
    text
    <p>We are trying to implement a feature for a famous pharmaceutical company website, which requires to retrieve images from facebook using a facebook API, to generate a resultant image file.</p> <p>However, we are facing technical difficulties retrieving images using API call, due to the randomized changes in domain and IP (sphotos-d.ak.fbcdn.net and a2.sphotos.ak.fbcdn.net ) of the URL from which the image is retrieved (due to CDN, DNS round robin and load balancing). The development environment is rather restricted and opening a wide range of IP addresses is not possible.</p> <p>Could you kindly advise us of an alternative solution to perform this API call to return a static URL or IP?</p> <p>More details of our implementation is provided below:</p> <p><strong>Function to get image from Facebook:</strong></p> <pre class="lang-js prettyprint-override"><code>function getAlbumPhotos(album_id) { var count = 1; id = album_id; //call FB to get JSON of all photos in an album - the response function is inline //and sets the output div with images and sets up click handlers FB.api('/' + id + '/photos', function (response) { var nHTML = ""; //build html for all photos for (var i = 0, l = response.data.length; i &lt; l; i++) { //photo ids photo_id = response.data[i]; //image url image_link = photo_id.source nHTML += fbPhotos(count, image_link); count++; } //set the html content nHTML = "&lt;h1&gt;"+__("select.friend")+"&lt;/h1&gt;" + nHTML + "&lt;div class='clear'&gt;&lt;/div&gt;"; $('#myContent').html(nHTML); Cufon.refresh(); //set click handlers for all new items for (var i = 0, l = response.data.length+1; i &lt; l; i++) { $('#fbphoto_' + i).click(fbPhoto_click); } hideBusy(); }); </code></pre> <p>The code FB.api('/' + id + '/photos', function (response) {}) The “id” is the album id which user choose. This statement will return the list of image data in json type which contain the image data (Ex. full image url, upload date, title)</p> <p>The “Full image url” will look like</p> <p><a href="http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc6/205045_1360429746128_61249_n.jpg" rel="nofollow">http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc6/205045_1360429746128_61249_n.jpg</a></p> <p><a href="http://sphotos-d.ak.fbcdn.net/hphotos-ak-ash4/s720x720/308224_1593433971088_1975239922_n.jpg" rel="nofollow">http://sphotos-d.ak.fbcdn.net/hphotos-ak-ash4/s720x720/308224_1593433971088_1975239922_n.jpg</a></p> <p>I use this URL to show image on the client and build the postcard</p> <p><strong>Building the Post Card:</strong></p> <p>Server (Build the postcard)</p> <pre><code>&lt;?php $LeftPath = "http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc6 /205045_1360429746128_61249_n.jpg"; $RightPath = "http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc6/205045_1360429746128_61249_n.jpg"; $Postcard = imagecreatefromjpeg('images/Postcard/postcard_BG.jpg'); $LeftImage = imagecreatefromjpeg($LeftPath); $RightImage = imagecreatefromjpeg($RightPath); imagealphablending($Postcard, false); imagesavealpha($Postcard, true); imagecopymerge($Postcard, $LeftImage, 336, 233, 0, 0, 300, 300, 100); imagecopymerge($Postcard, $RightImage, 642, 276, 0, 0, 300, 300, 100); header('Content-Type: image/jpeg'); imagejpeg($Postcard, NULL, 75); ?&gt; </code></pre> <p>On the server I get the image by “Full image url” from facebook and merge it with the internal postcard image ('images/Postcard/postcard_BG.jpg') using GD Libraly from PHP</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload