<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Facebook API Archives : vedmant.com : coding blog</title>
	<atom:link href="https://vedmant.com/tag/facebook-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://vedmant.com/tag/facebook-api/</link>
	<description>Sharing my personal experience in web development</description>
	<lastBuildDate>Fri, 28 Oct 2016 16:08:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>Facebook Graph API &#8211; upload photo using JavaScript from local computer</title>
		<link>https://vedmant.com/facebook-graph-api-upload-photo-using-javascript-local-computer/</link>
					<comments>https://vedmant.com/facebook-graph-api-upload-photo-using-javascript-local-computer/#comments</comments>
		
		<dc:creator><![CDATA[vedmant]]></dc:creator>
		<pubDate>Fri, 28 Oct 2016 16:02:15 +0000</pubDate>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebook API]]></category>
		<category><![CDATA[Facebook Graph API]]></category>
		<guid isPermaLink="false">https://vedmant.com/?p=124</guid>

					<description><![CDATA[<p>Hi everyone, recently I encountered a problem with uploading photos to Facebook using Graph API with JavaScript. And there were no working solutions on Stack Overflow nor some example in official Facebook documentation. So I have to figure out something, and here is how I do it: Try out this working example facebook-upload-photos you will &#8230; <a href="https://vedmant.com/facebook-graph-api-upload-photo-using-javascript-local-computer/" class="more-link">Continue reading <span class="screen-reader-text">Facebook Graph API &#8211; upload photo using JavaScript from local computer</span></a></p>
<p>The post <a href="https://vedmant.com/facebook-graph-api-upload-photo-using-javascript-local-computer/">Facebook Graph API &#8211; upload photo using JavaScript from local computer</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi everyone, recently I encountered a problem with uploading photos to Facebook using Graph API with JavaScript. And there were no working solutions on Stack Overflow nor some example in official Facebook documentation.</p>
<p>So I have to figure out something, and here is how I do it:</p>
<pre class="brush: jscript; title: ; notranslate">

$('#button_upload').click(function (e) {
   e.preventDefault();

    // Get file object from file input
    var file = $('#input_file')&#x5B;0].files&#x5B;0];

    // If file is selected
    if (file) {
        // We will use FileReader
        var reader = new FileReader();
        // And and onload callback when file data loaded
        reader.onload = function (e) {
            // This is array buffer of the file
            var arrayBuffer = e.target.result;
            // And blob object of the file
            var blob = new Blob(&#x5B;arrayBuffer], { type: file.type });

            // We will use FormData object to create multipart/form request
            var data = new FormData();
            data.append('access_token', FB.getAccessToken());
            data.append('source', blob);
            data.append('message', $('#input_description').val());

            $('#uploading').show();

            // Send the request manually with jQeury
            $.ajax({
                url: 'https://graph.facebook.com/me/photos?access_token=' + FB.getAccessToken(),
                type: 'POST',
                data: data,
                processData: false,
                contentType: false,
                cache: false,
                success:function (data) {
                    $('#status').append('&lt;p&gt;Photo was successfully uploaded, object id is: ' + data.id + '&lt;/p&gt;');
                    console.log(data)
                },
                error:function (data) {
                    console.log(data);
                },
                complete: function () {
                    $('#uploading').hide();
                }
            });

        };
        // Read file as array buffer to create blob object
        reader.readAsArrayBuffer(file);
    }
});

</pre>
<p>Try out this working example <a href="https://vedmant.com/wp-content/uploads/2016/10/facebook-upload-photos.html" target="_blank">facebook-upload-photos</a> you will need to use test user &#8220;open_gestmxg_user@tfbnw.net&#8221; and password &#8220;123Qweasd&#8221;.</p>
<p>Notes: to upload photos you will need to create a facebook application with permission &#8220;publish_actions&#8221; and &#8220;user_photos&#8221;.</p>
<p>The post <a href="https://vedmant.com/facebook-graph-api-upload-photo-using-javascript-local-computer/">Facebook Graph API &#8211; upload photo using JavaScript from local computer</a> appeared first on <a href="https://vedmant.com">vedmant.com :: coding blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vedmant.com/facebook-graph-api-upload-photo-using-javascript-local-computer/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
