c# 4.0 - How to upload images to facebook which is selected by using photoChooserTask in windows phone 8? -


i developing windows phone app in have post photo facebook. , particular photo choosen using photochoosertask or camerachoosertask.

normally, can post particular photo successfully, facing problem post selected photo. saw link link

so please if know issue please me out. thanx in advance.

edit

private void postclicked(object sender, routedeventargs e)     {         //client parameters         var parameters = new dictionary<string, object>();         //var parameters1 = new dictionary<>();         parameters["client_id"] = fbapi;         parameters["redirect_uri"] = "https://www.facebook.com/connect/login_success.html";         parameters["response_type"] = "token";         parameters["display"] = "touch";         parameters["contenttype"] = "image/png";         //the scope give access users data, in case         //we want publish on wall         parameters["scope"] = "publish_stream";         browser.visibility = system.windows.visibility.visible;         browser.navigate(client.getloginurl(parameters));     } private void browsernavitaged(object sender, system.windows.navigation.navigationeventargs e)     {         facebookoauthresult oauthresult;         //making sure url has access token         if (!client.tryparseoauthcallbackurl(e.uri, out oauthresult))         {             return;         }         //checking user accepted our app, otherwise show error         if (oauthresult.issuccess)         {             //process result             client.accesstoken = oauthresult.accesstoken;             //hide browser             browser.visibility = system.windows.visibility.collapsed;             posttowall();         }         else         {             //process error             messagebox.show(oauthresult.errordescription);             browser.visibility = system.windows.visibility.collapsed;         }     } private void posttowall()     {         string imagename = "ic_launcher.png";         streamresourceinfo sri = null;         uri jpeguri = new uri(imagename, urikind.relative);         sri = application.getresourcestream(jpeguri);         try         {             byte[] imagedata = new byte[sri.stream.length];             sri.stream.read(imagedata, 0, system.convert.toint32(sri.stream.length));             facebookmediaobject fbupload = new facebookmediaobject             {                 filename = imagename,                 contenttype = "image/jpg"             };             fbupload.setvalue(imagedata);             string name1 = eventname.text;             string format = "yyyy-mm-dd";             string message1 = eventmessage.text;             string date1 = datepicker.valuestring;             datetime datevalue = datetime.parse(date1);             string d = datevalue.tostring(format);             string memotype = "tribute";             var parameters = new dictionary<string, object>();             var parameters1 = new dictionary<string, object>();             parameters["message"] = name1 + "\n" + d + "\n" + memotype + "\n" + message1;             parameters["source"] = fbupload;              webservice();             client.posttaskasync("me/photos", parameters);         }         catch (exception error)         {             messagebox.show(error.tostring());         }          //client.posttaskasync("me/photos", parameters1);     } 

on clicking on button calling postclicked class , directly go facebook mainpage , ask login information. doing. please check out

now can share photo facebook using photochoosertask or cameratask. sharing experience if face same issue can use it.

private void photochoosertask_completed(object sender, photoresult e)     {         bitmapimage image = new bitmapimage();         image.setsource(e.chosenphoto);         saveimagetoisolatedstorage(image, tempjpeg);         this.image.source = image;     } public void saveimagetoisolatedstorage(bitmapimage image, string filename)     {         using (var isolatedstorage = isolatedstoragefile.getuserstoreforapplication())         {             if (isolatedstorage.fileexists(filename))                 isolatedstorage.deletefile(filename);             var filestream = isolatedstorage.createfile(filename);             if (image != null)             {                 var wb = new writeablebitmap(image);                 wb.savejpeg(filestream, wb.pixelwidth, wb.pixelheight, 0, 100);             }             filestream.close();         }     } 

with can able save selected image isolatedstorage. , @ time of posting photo facebook have select image isolatedstorage.

private void postclicked(object sender, routedeventargs e)     {         //client parameters         var parameters = new dictionary<string, object>();         parameters["client_id"] = fbapi;         parameters["redirect_uri"] = "https://www.facebook.com/connect/login_success.html";         parameters["response_type"] = "token";         parameters["display"] = "touch";         //the scope give access users data, in case         //we want publish on wall         parameters["scope"] = "publish_stream";         browser.visibility = system.windows.visibility.visible;         browser.navigate(client.getloginurl(parameters));     } private void browsernavitaged(object sender, system.windows.navigation.navigationeventargs e)     {         facebookoauthresult oauthresult;         //making sure url has access token         if (!client.tryparseoauthcallbackurl(e.uri, out oauthresult))         {             return;         }         //checking user accepted our app, otherwise show error         if (oauthresult.issuccess)         {             //process result             client.accesstoken = oauthresult.accesstoken;             //hide browser             browser.visibility = system.windows.visibility.collapsed;             posttowall();         }         else         {             //process error             messagebox.show(oauthresult.errordescription);             browser.visibility = system.windows.visibility.collapsed;         }     } private void posttowall()     {         try         {             byte[] data;             using (isolatedstoragefile myisolatedstorage = isolatedstoragefile.getuserstoreforapplication())             {                 using (isolatedstoragefilestream filestream = myisolatedstorage.openfile(tempjpeg, filemode.open, fileaccess.read))                 {                     data = new byte[filestream.length];                     filestream.read(data, 0, data.length);                     filestream.close();                 }             }             //memorystream ms = new memorystream(data);             //bitmapimage bi = new bitmapimage();             //// set bitmap source memory stream              //bi.setsource(ms);             //this.imagetribute.source = bi;             facebookmediaobject fbupload = new facebookmediaobject             {                 filename = tempjpeg,                 contenttype = "image/jpg"             };             fbupload.setvalue(data);             string name1 = eventname.text;             string format = "yyyy-mm-dd";             string message1 = eventmessage.text;             string date1 = datepicker.valuestring;             datetime datevalue = datetime.parse(date1);             string d = datevalue.tostring(format);             string memotype = "notice";             var parameters = new dictionary<string, object>();             var parameters1 = new dictionary<string, object>();             parameters["message"] = name1;             parameters["source"] = fbupload;             webservice();             client.posttaskasync("me/photos", parameters);          }         catch (exception error)         {             messagebox.show(error.tostring());         }     } 

thanx all....


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -