WebClient Can't download Page WP8 - webclient

I have some problem with this Code
Webclient wc= new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync(new Uri("http://tv.csmtalk.vn"));
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
MessageBox.Show(e.Result);
}
Some site such as "google.com.vn" the result is nice. But when i use the site "tv.csmtalk.vn" the result is nothing. but viewsource in Chrome , firefox, IE is ok.
anyone can help me?

Related

Sharing screenshot with text to facebook unity

I'm trying to give the user the possibility to post a screenshot of his game on facebook with the dowload link of the game.
I've looked a bit and it seemed it would be possible with FB.API, but I can't manage to make it work.
Aparently you need a permission but I can't to find which permission and how to give it.
I'm using unity 2020.3.21f1
Here is what I'm doing for now
public void ShareScreenShot(Texture2D screenShot)
{
byte[] encodedScreenShot = screenShot.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", encodedScreenShot, "ScreenShot.png");
wwwForm.AddField("message", "Venez me défier : https://randomlink.blablabla");
FB.API("me/photos", HttpMethod.POST, ShareScreenShotCallback, wwwForm);
}
void ShareScreenShotCallback(IResult result)
{
if (result.Error != null)
{
Debug.Log(result.Error);
}
else
{
Debug.Log("sharing success");
}
}
If anyone of you knows how it can be done, it would be of great help, thanks
I suppose you need to login to facebook with custom permissions, because the default one only allows you to send invitations to choosen friends.
https://developers.facebook.com/docs/unity/reference/current/FB.LogInWithPublishPermissions/

how to share to facebook without showing feed dialog in android application?

I tried a lot about sharing to facebook without showing dialog using facebook android sdk,but could not get solution. Please help me to share to facebook without dialog.
Use GraphReqest. This code posts a Bitmap image on facebook with caption using facebook sdk 4.2
Bitmap bmp;
String caption;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
final JSONObject graphObject=new JSONObject();
Callback callback=new Callback() {
#Override
public void onCompleted(GraphResponse response) {
// your code
}
};
GraphRequest request=GraphRequest.newPostRequest(AccessToken.getCurrentAccessToken(), "me/photos", graphObject, callback);
Bundle params = new Bundle();
//params.putString("method", "photos.upload");
params.putString("caption", caption);
params.putByteArray("picture", byteArray);
request.setParameters(params);
request.executeAsync();
You will have to take publish_actions permissions from the user
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
Moreover, If your app requires publish_actions, then you also need to send your app for the review on fb developers page, otherwise it will only work for developer accounts and tester accounts.

Is there any way to specify facebook-links with the HTTP protocol which opens the app (iPhone/Androdi) if installed?

So I know the Facebook-app supports the fb:// URL scheme. But does it also support a URL scheme for HTTP?
I've tried for instance https://www.facebook.com/Google, and it does not yield an option to open the app, when clicked on from Chrome on an HTC One M8 device. So obviously Facebook haven't defined a URL scheme to match that URL. But they might have created others? Theoretically they could for instance have a scheme that triggered when a sub-url contains /app or something.
My goal is to link to a Facebook profile page which opens in the app if it is installed, and in the browser if not. Without using any Javascript. If facebook have defined a schema matching any HTTP-protocol, it is possible.
I made this work for link to google play with this function, changing te protocol to the facebook could work
public void getpro(View view) {
final String appName = BuildConfig.APPLICATION_ID;
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName")));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+appName")));
}
}
to:
public void getpro(View view) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("facebook://facebook.com/inbox")));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com")));
}
}
You can try to achieve this with Intents. I found this:
String uri = "facebook://facebook.com/inbox";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
Intent is used to call other applications while using an application.

Logging out from facebook using facebook c# sdk in WP7

I want to implement logout from facebook using facebook C# sdk in my windows phone app
My primary question is how do we logout using Facebook C# SDK in WP7
I found this article in search
Article link
there he is trying to find the logout url using regex, but that did not working in my app
when i try that the browser navigated event is going into infinite loop
you can share any samples/posts related to facebook logout in windows phone 7.
I want logout should happen with out user intervention, after he clicks on a button he should looged out from facebook and from next time he should see the login page
I tried following posts/blogs also but no use.
LINK 1
LINK 2 this giving error while splitting the accesstoken
UPDATE
LogOutButtonCode
FacebookClient _fbClient = new FacebookClient(fbaccess.AccessToken);
var logoutParams = new Dictionary<string, object>();
logoutParams.Add("next", "https://www.facebook.com/connect/login_success.html");
//logoutParams.Add("",)
var logoutUrl = _fbClient.GetLogoutUrl(logoutParams);
BrowserControl.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(BrowserControl_Navigated);
BrowserControl.Navigate(new Uri(logoutUrl.AbsoluteUri));
Navigated Event CODE
if (e.Uri.AbsoluteUri == "https://www.facebook.com/connect/login_success.html")
{
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
e.Uri.AbsoluteUri returns https://www.facebook.com/home.php
Logout URL i am getting from the server https://www.facebook.com/logout.php?next=https://www.facebook.com/connect/login_success.html
Use FacebookClient.Logout to generate the logout url.
This is the snippet from winforms sample which will work in wp7 with some modifications.
private void btnLogout_Click(object sender, EventArgs e)
{
var fb = new FacebookClient();
var logoutUrl = fb.GetLogoutUrl(new
{
next = "https://www.facebook.com/connect/login_success.html",
access_token = _accessToken
});
var webBrowser = new WebBrowser();
webBrowser.Navigated += (o, args) =>
{
if (args.Url.AbsoluteUri == "https://www.facebook.com/connect/login_success.html")
Close();
};
webBrowser.Navigate(logoutUrl.AbsoluteUri);
}
Make sure to persist the access token somewhere when you login as it is required to logout.

GWT Progress Bar while buffering PDF content before displaying on browser

In my GWT app I have written a servlet to download/stream a PDF file.
Following is the code.
protected void updateResponse(HttpServletResponse response, InputStream dataStream, long contentLength, KnownContentTypes contentType, String filename, int cacheSeconds) {
response.setHeader("Content-Type", contentType.getTypeString());
response.setHeader("Content-Length", String.valueOf(contentLength));
response.setHeader("Content-disposition", "inline;filename=" + filename);
response.setHeader("Cache-Control", "max-age=" + cacheSeconds);
byte[] buffer = new byte[BUFFER_SIZE];
try {
ServletOutputStream out = response.getOutputStream();
while ((dataStream.read(buffer)) != -1) {
out.write(buffer);
}
} catch (IOException e) {
sendError(response);
}
}
The pdf is successfully rendered on the browser.
The problem is some pdf's are really large in size and since this is called on window.open all I see is a blank browser.
I want to display a dynamic message like '1MB of 5MB downloaded' and display/render the entire PDF file once all bytes are streamed.
Please let me know how to do this.
I am new to GWT and any help will be appreciated.
Thanks.
This can not be done with synch request which we usually make by calling servlet with Window.open You have to make ajax request to calculate progress and display the response.
Take a look to this library: http://code.google.com/p/gwtupload/. It is really easy to to use and works fine in most of the browsers. It uses ajax requests to calculate progress.