How can solve OAuthException while i am post a message on facebook - android

i am doing a sample Facebook application in that i am POST a file to a particular person only, while i am doing this i got an error message like..
05-27 14:33:51.806: DEBUG/Response(2211): {"error":{"type":"OAuthException","message":"(#803) Some of the aliases you requested do not exist: friends"}}
Code:
Bundle b = new Bundle();
accesstoken = facebook.getAccessToken();
b.putString("method", "read_stream");
b.putString("attachment","{\"name\":\"" + "\",\"href\":\"google.co.in"; + "\",\"description\":\"" + "\",\"media\":[{\"type\":\"image\",\"src\":\"" + "" + "\",\"href\":\"" + "\"}]}");
String response = facebook.request("friend_id", b, "POST");

Have you tried to check documentation for facebook and obtain knowledge, that "friends" is wrong, you should use "friend" or "friendlist" instead.

Related

Invalid Request when debuging on Android devide, Xamarin

I'm writing a project in Xamarin Forms, and today we try our app on Android device. And our request to googleAPI stop working. Here's code :
HttpWebRequest webRequest = WebRequest.Create(#"https://maps.googleapis.com/maps/api/place/search/json?location=" + position.Latitude + "," + position.Longitude + "&radius=1000&types=bar&sensor=false&key=APIKEY") as HttpWebRequest;
webRequest.Method = "GET";
webRequest.BeginGetResponse(new AsyncCallback(RequestCompleted), webRequest);
and then :
var request = (HttpWebRequest)result.AsyncState;
var response = (HttpWebResponse)request.EndGetResponse(result);
using (var stream = response.GetResponseStream())
{
var r = new StreamReader(stream);
var resp = r.ReadToEnd();
}
We got response and change it to json. On computer it works OK, but on Android it is saying INVALID REQUEST. Someone worked with Xamarin and know how to solve it?
If I would have to guess, I'd guess, that the locale/ language on your phone is different to that one on your pc.
HttpWebRequest webRequest = WebRequest.Create(#"https://maps.googleapis.com/maps/api/place/search/json?location=" + position.Latitude + "," + position.Longitude + "&radius=1000&types=bar&sensor=false&key=APIKEY") as HttpWebRequest;
There are implicit ToString() at ...n=" + position.Latitude + "," + position.Longitude + "&ra... that produce a localized output. But the google API needs the values with a . as decimal separator.
Append .ToString("G", CultureInfo.InvariantCulture)
HttpWebRequest webRequest = WebRequest.Create(#"https://maps.googleapis.com/maps/api/place/search/json?location=" +
position.Latitude.ToString("G", CultureInfo.InvariantCulture) +
"," + position.Longitude.ToString("G", CultureInfo.InvariantCulture) +
"&radius=1000&types=bar&sensor=false&key=APIKEY") as HttpWebRequest;

Google api login gives Error 500 in Webview

I am using WebView in my app for google login.
private static final String SCOPE_PLUS_LOGIN = "https://www.googleapis.com/auth/plus.login";
private static final String SCOPE_PLUS_USER_INFO_EMAIL = "https://www.googleapis.com/auth/userinfo.email";
private static final String SCOPE_PLUS_USER_INFO_PROFILE = "https://www.googleapis.com/auth/userinfo.profile";
void loadUrl() {
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("https://accounts.google.com/o/oauth2/auth?scope=" + SCOPE_PLUS_LOGIN + "+" + SCOPE_PLUS_USER_INFO_EMAIL + "+" + SCOPE_PLUS_USER_INFO_PROFILE + "&redirect_uri=" + GOOGLE_REDIRECT_URL + "&response_type=code&client_id=" + GOOGLE_CLIENT_ID;);
}
First login works fine, I typed email, password, google show scopes permissions. But on the second login I got 500 error on url like this:
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/plus.login+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&response_type=code&redirect_uri=my_redirect_url&client_id=my_client_id&hl=uk&from_login=1&as=478a8e5eead4aff6
What reason of such behavior? I checked client_id and redirect url - they are fine.
You cannot get new access token because your old one has not expired yet.
You must get the access token ONCE, save it somewhere and use it until it expires, you can not get new access token each time you try to query something
to revoke your first access token go to Google API Console and you will find it under Client ID for installed applications

Microsoft Sync Framework - ServerBlob is Empty Error

I am using Microsoft Sync Framework to sync the details from the Datadictionary on android device with SQL Server. Initially get success to sync all data from sql server. But after adding some data and when clicking on the Sync button getting the following error. Can you please tell me is anybody came across this?
[Sync Error]:Error occurs during sync. Please check logs below.
[Upload Change Response Error]: 500 Response: <ServiceError xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Synchronization.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorDescription>System.InvalidOperationException
 serverBlob is empty
 at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.ApplyChanges(Byte[] serverBlob, List`1 entities)
 at Microsoft.Synchronization.Services.UploadChangesRequestProcessor.ProcessRequest(Request incomingRequest)
 at Microsoft.Synchronization.Services.SyncService`1.ProcessRequestForMessage(Stream messageBody)
 
 
 </ErrorDescription></ServiceError>
In the below code, i'm getting xmlHttp.status=500 when clicking on the Sync button
this.sendRequest = function (serviceUri, successCallback, errorCallback, dir) {
TraceObj("[" + dir + " Request]:", serviceUri, this.dataObject());
// Construct HTTP POST request
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", serviceUri);
xmlHttp.setRequestHeader("Accept", "application/json");
xmlHttp.setRequestHeader("Content-Type", "application/json");
// Handle success & error response from server and then callback
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var res = new SyncFormatter();
if (res.parse(xmlHttp.responseText)) {
TraceObj("[" + dir + " Response]:", serviceUri, res.dataObject());
alert("[" + dir + " Response]:", serviceUri, res.dataObject());
successCallback(res);
return;
}
}
TraceMsg("[" + dir + " Response Error]: ", xmlHttp.status + " Response: " + xmlHttp.responseText);
errorCallback(xmlHttp.responseText);
}
};
xmlHttp.send(this.toString());
};
}
I have found the root cause of the problem. That is when i get the values from datadictionary storage, value has the single quotes in the values so not able to load the values in webview. Now i have replaced single quotes by \'. Now working fine.

Not able to tag photos on facebook using the android sdk

I am using the following code (from sdk examples "Hackbook") to add a tag to a photo after uploading it.
json = Util.parseJson(response);
photo_id = json.getString("id");
String relativePath = photo_id + "/tags/" + Utility.userUID;
Bundle params = new Bundle();
params.putString("x", "25");
params.putString("y", "25");
Utility.mAsyncRunner.request(relativePath, params, "POST", new TagPhotoRequestListener(), null);
However, I sometimes (not always) receive the the response from facebook as "false" instead of "true". Is there a specific reason for this?
Additionally, is there a way to tag the photo while uploading it, instead of making an additional call?

android facebook page like

i want to like a facebook page in my android app..is there any API for this?i tried a code.it was working intially.but now it is not working
likeWebView = (WebView) findViewById( R.id.webView1 );
likeWebView.getSettings().setJavaScriptEnabled(true);
String url = "http://www.facebook.com/plugins/like.php?" +
"href=" + URLEncoder.encode("likeurl" ) + "&" +
"layout=standard&" +
"show_faces=false&" +
"width=500&" +
"action=like&" +
"colorscheme=light&" +
"access_token=" + URLEncoder.encode( "read_stream" );
likeWebView.loadUrl( url );
please help me.I have been working on this for a long time.
First of all u have to create facebook developer forum account. then download facebook API which ill include in your project.
You can customized the facebook API according your requirement.
This url can help you http://forum.developers.facebook.net
:)

Categories

Resources