EDIT: I've found the solution.
The right magic word is: [QBCustomObjects objectsWithClassName:#"Settings" extendedRequest:(NSMutableDictionary*)#{#"user_id": [NSNumber numberWithInt:userID]} delegate:self];
I was fooled by QuickBlox web interface, I saw the field "User ID" but its' right name is "user_id".
Igor, thanks for link: http://quickblox.com/developers/Custom_Objects#Module_description
After logging in I immediately try to load a custom object belongs to the user. Code:
[QBCustomObjects objectsWithClassName:#"Settings" extendedRequest:(NSMutableDictionary*)#{#"User ID": [NSNumber numberWithInt:userID]} delegate:self];
And I have this error:
Performing async request:
RestRequest:
------
GET http://api.quickblox.com/data/Settings.xml
headers:{
"QB-SDK" = "iOS 1.7.1";
"Qb-Token" = 7cca2175045d14f5268d665b19e798f7240b5119;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"User ID" = 503563;
}
raw body:
2013-09-10 14:54:30.771 DimChat[48597:6c0f] Request failed, response:
RestResponse:
------
<QBASIHTTPRequest: 0x996ae00>
headers:(null)
body:
error:Error Domain=QBASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x7d693e0 {NSLocalizedDescription=Unable to create request (bad url?)}
2013-09-10 14:54:30.771 DimChat[48597:c07] (
"Connection closed due to timeout. Please check your internet connection."
)
May be I do something wrong?
I can create a new custom object in user event handler and even I can (re)load the created object using it's ID
[QBCustomObjects objectWithClassName:#"Settings" ID:co.ID delegate:self];
But I need to load a custom object when I know only User ID and immediately after login.
There is a table with pre-defined fields explanation (in bold) http://quickblox.com/developers/Custom_Objects#Module_description
Related
We have an airtable database of over 24000 records. These records are websites, and many now have errors in them (missing "/", extra space...). We are trying to detect the websites that have these errors before manually fixing them.
What we have tried
So far, we have used the fetch method to call each URL and report back on the error status . This is the script we have used:
const inputConfig = input.config();
const url = inputConfig.url;
let status;
try {
const response = await fetch(url);
status = response.status; } catch (error) {
status = 'error'; }
output.set('status', status);
Issues we ran into
The script won't follow redirects, so it reports "error" back if there is a redirect even if the URL is working.
The output now is either "200" meaning the URL works, or "error". We don't get the actual response code of the error, which we ideally would like to get.
Any help would be appreciated! Thanks
There's some nuance to how fetch works. If you review Mozilla's documentation they say:
The Promise returned from fetch() won't reject on HTTP error status even if the response is an HTTP 404 or 500. Instead, as soon as the server responds with headers, the Promise will resolve normally (with the ok property of the response set to false if the response isn't in the range 200–299), and it will only reject on network failure or if anything prevented the request from completing.
So you have to do an extra check in your code to determine if the request was successful or not and throw your own error. In your case, you don't necessarily need to throw an error at all and can just rely on ok property of the response.
const config = input.config();
const url = config.url;
let status = null;
const response = await fetch(url);
if(response.ok) {
status = response.status
} else {
status = 'error'
}
output.set('status', status);
I am using QuickBlox iOS SDK (version 2.9.2) and got a failure with error code 422 when calling
[QBRequest createObject:qbcoCustomObject successBlock:^(QBResponse *response, QBCOCustomObject *object) {
} errorBlock:^(QBResponse *response) {
}];
It happens OCCASIONALLY and does not resume until I logout and login QuickBlox again.
The error message is as follows:
2017-04-24 06:18:45.855557 App[8720:4958563] [QBCore] Response error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: client error (422)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17422ed40> { URL: https://api.quickblox.com/data/MyCircleComments.json } { status code: 422, headers {
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 45;
"Content-Type" = "application/json; charset=utf-8";
Date = "Mon, 24 Apr 2017 12:18:45 GMT";
"QB-Token-ExpirationDate" = "2017-04-24 14:09:35 +0000";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "openresty/1.9.15.1";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 89f509abd6fd7f61d02e34ae9e83ce70;
"X-Runtime" = "0.009477";
"X-UA-Compatible" = "IE=Edge,chrome=1";
} }, NSErrorFailingURLKey=https://api.quickblox.com/data/MyCircleComments.json, com.alamofire.serialization.response.error.data=<7b226572 726f7273 223a7b22 62617365 223a5b22 466f7262 69646465 6e2e204e 65656420 75736572 2e225d7d 7d>, NSLocalizedDescription=Request failed: client error (422)}
2017-04-24 06:18:45.856659 App[8720:4958563] [QBCore] Response error reasons: {
errors = {
base = (
"Forbidden. Need user."
);
};
}
Due to the fact that it resumes only after I logout and login again, I was thinking that it may be related to session expiry. I added login method at the app's didFinishLaunching and didBecomeActive so that the app will automatically re-login to make sure the login session be valid. The login method I use is
[QBRequest logInWithUserLogin:sUsername password:sPassword successBlock:^(QBResponse *response, QBUUser *user) {
} errorBlock:^(QBResponse *response) {
}];
and by setting breakpoints I am sure each time the auto relogin did succeed.
However, app's auto-relogin does not work. The failure still happens occasionally and the only way out is logout and login manually.
I googled this issue and found a bunch of topic but none seems to meet my problem. (One post suggests that the time of device may not be synchronized but actually my iPhone is using the network time.)
Can anyone give me a hint why it fails and a solution is highly appreciated. Thanks in advance.
One of the best answer for above issue:-
**"Bad timestamp means that you send invalid timestamp value on session creation, which is based on your phone time. Your device time shouldn't differ from server more than 2 hours.
We suggest you synchronize time on your devices with NTP service or just set tick 2 checkboxes in Settings in your device: Automatic date & time and Automatic time zone.
Hope this help"**
Ref :- https://github.com/QuickBlox/quickblox-ios-sdk/issues/452
From setting of the device set timezone automatic on.
Hope this will help you.
Try to get Quickblox session token
[[[QBSession currentSession] sessionDetails] token];
And check session type via REST API
//QuickBlox Documentation
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 8b75a6c7191285499d890a81df4ee7fe49bc732a" \
https://api.quickblox.com/session.json
If field "user_id" of your token will be equal to 0 this mean that you have "application-token" type, and you cannot create or update items on QBlox, after login with session token "upgrades" to "user-token"
I have similar issue, and i made extra check, if token-type is application, then you need login with same user again (recursively call login method if you can), i know that its a workaround, but we cant dig deeper because all locked in Quickblox.framework
I have been able to authenticate with the Pinterest API on both the javascript and Android SDK. On iOS, I've triple-checked all of my settings to make sure I've configured everything according to the documentation.
However, when I log in through iOS, I am taken to the Pinterest app to authorize and all looks good. However, when Pinterest passes me back to my app, I am getting the following login error:
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17403dea0> { URL: https://api.pinterest.com/v1/oauth/inspect?access_token=AYalMni-yTq5Y0UihwETrFxZpzL5FK2tXvfmkbhDyJ_OP8BGeQAAAAA&token=AYalMni-yTq5Y0UihwETrFxZpzL5FK2tXvfmkbhDyJ_OP8BGeQAAAAA } { status code: 401, headers {
Age = 0;
"Cache-Control" = private;
Connection = "keep-alive";
"Content-Length" = 177;
"Content-Type" = "application/json";
Date = "Mon, 20 Mar 2017 19:21:15 GMT";
"Pinterest-Generated-By" = "devplatform-devapi-prod-0a01239b";
"Pinterest-Version" = 918ef75;
"X-Content-Type-Options" = nosniff;
"X-Pinterest-RID" = 280542321780;
} }, NSErrorFailingURLKey=https://api.pinterest.com/v1/oauth/inspect?access_token=AYalMni-yTq5Y0UihwETrFxZpzL5FK2tXvfmkbhDyJ_OP8BGeQAAAAA&token=AYalMni-yTq5Y0UihwETrFxZpzL5FK2tXvfmkbhDyJ_OP8BGeQAAAAA, com.alamofire.serialization.response.error.data=<7b227374 61747573 223a2022 6661696c 75726522 2c202263 6f646522 3a20332c 2022686f 7374223a 20226465 76706c61 74666f72 6d2d6465 76617069 2d70726f 642d3061 30313233 3962222c 20226765 6e657261 7465645f 6174223a 20224d6f 6e2c2032 30204d61 72203230 31372031 393a3231 3a313520 2b303030 30222c20 226d6573 73616765 223a2022 41757468 6f72697a 6174696f 6e206661 696c6564 2e222c20 22646174 61223a20 6e756c6c 7d>, NSLocalizedDescription=Request failed: unauthorized (401)}
I tried taking the access token referred to in the error response and using the token debugger on the Pinterest developer site to check it, but when I did so I got the message "An error occurred. Please try again."
So, I'm stumped. It seems to me that the access token that's being generated on iOS login is being seen as invalid by Pinterest, but I don't know how to fix that.
Do you have any thoughts on what can be done to resolve this?
I have a weird issue happening when trying to set blobID for the existing user zero. This has worked earlier and I do not know what may be causing this.
In relation to item:
Quickblox: an issue in deleting content item (picture file / blob)
I need to remove blob/content reference from the user in order to remove the user object completely. Now, when trying to set blobID as zero, it does not change but instead updateUsers will return "No data was provided".
So I tried to change also some other data, such as fullName & tags in order to see if any data changes with user object: this query returns sucecss and these other fields have been changed (confirmed with QB admin panel) but blobID is ignored/not changed.
My code:
QBUUser *user = [QBUUser user];
user.ID = self.currentUser.ID; // current user QB ID
user.tags = [[NSArray arrayWithObjects:#"DELETED", nil] mutableCopy];
user.fullName = #"DELETED";
user.blobID = 0;
[QBUsers updateUser:user delegate:self context:contextUpdateProfile];
Logs:
<Warning>: Performing async request:
PUT http://api.quickblox.com/users/723606u.xml?user%5Bfull_name%5D=DELETED&user%5Btag_list%5D=DELETED
headers:{
"QB-SDK" = "iOS 1.8.1";
"Qb-Token" = 1738d8c1e14a448da4e232ca81d087d1756c6a9b;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:
{...other_debugs_coming_up...}
<Warning>: -[MyBackend completedWithResult:context:]1659| AA QBUUserResult - contextUpdateProfile: user updated succesfully.
What am I doing incorrectly? I am pretty sure this has worked earlier as I have been able to remove users with the same process and have tried to dig into my code if I have changed anything but without success.. :(
Any suggestions/tips are appreciated.
Can anyone help me , I want to Download the connection of LinkedIn and Add into iPhone Address Book.
I googled it but not getting any help.
I am using following Api :
NSURL *url = [NSURL URLWithString:#"http://api.linkedin.com/v1/people/~/connections"];
and I am getting the response like:
profile {
errorCode = 0;
message = "Access to connections denied";
requestId = GVG2FXA2N0;
status = 403;
timestamp = 1366641414499;
}
There is AddressBook framework for that:
http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/
a wrapper library:
http://maniacdev.com/2012/02/open-source-ios-address-book-wrapper-library-providing-automatic-hashing-and-permission-alerts/
Simple tutorial:
http://programming4.us/mobile/9260.aspx
You must be missing r_network scope.Even I was getting same error. But when I added r_network scope the problem resolved