I am trying to develop a Moodle Android app. I am using MoodleREST source code for my reference.Is there any other documentation on Moodle site which documents moodle core webservice functions with their required params.
I have found list of functions here http://docs.moodle.org/dev/Web_services_Roadmap but could not get proper documentation on how to call these functions with required params from mobile client using REST.
I am new to moodle and still learning it, so my question can be a little naive so please bear with it :)
This could be helpful http://docs.moodle.org/dev/Creating_a_web_service_client
And if you have some administrator access to Moodle, go to
yourmoodle/admin/webservice/documentation.php , or
Administration > Plugins > Web services > API Documentation.
There is API with documentation. (Dont know if there is better way though :/)
D.
AIUI you need admin to access the most comprehensive web service API, as described by #Dolfa. You'll need these docs and/or the source if you're developing against their REST API. The API docs are generated from the source, presumably so they accurately reflect the API in the installed version.
You could:
Browse the code on github
Clone the version you intend to program against so you can browse the code locally
Install it and give yourself admin so you can browse the API docs.
If you don't want to go through the hassle of setting up a local Moodle instance, you may be able to figure out a way to run the php that generates the docs.
Once you have a rough idea of an API call, you can often find out the details by looking at responses to command-line requests e.g.
curl 'https://your.domain/webservice/rest/server.phpmoodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=[your_ws_token]' --compressed | python -m "json.tool"
gives the response
{
"debuginfo": "Missing required key in single structure: userid",
"errorcode": "invalidparameter",
"exception": "invalid_parameter_exception",
"message": "Invalid parameter value detected"
}
indicating that the function requires a userid=[userid] argument.
Related
I'm trying to provision a device with QR code method according to these documentations.
I'm using this Google collab quickstart guide to do so.
Right now, I'm stuck here:
enrollment_token = androidmanagement.enterprises().enrollmentTokens().create(
parent=enterprise_name,
body={
"policyName": policy_name,
"qrCode": "{'android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME': 'com.tmp.app.admin/.AdminReceiver','android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM': 'MUQ6NEQ6MDQ6NTY6M0E6ODA6Mzg6NEY6NUM6ODI6Qzk6NUY6MkM6QjA6RTk6RDc6QTM6RjI6NDg6NTA6QTQ6RjY6QTA6RjM6MTA6NUM6MzI6NkY6QkU6NUI6M0E6Qzk%3D','android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION':'https://myurl-stuff.com/link_part/my_app.apk','android.app.extra.PROVISIONING_SKIP_ENCRYPTION': false,'android.app.extra.PROVISIONING_WIFI_SSID': 'MY_WIFI_SSID','android.app.extra.PROVISIONING_WIFI_PASSWORD': 'my_wifi_password','android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE': 'WPA'}"
}
).execute()
json.dumps(enrollment_token, indent=2)
Whenever I run this code, the output is the following.
{\n "name": "enterprises/LC00y54m79/enrollmentTokens/UV4yLfxoyWSln7CArwtp7OJQiHH_Gvc76JttPa4-r48",\n "value": "ZBNWPOWHBQUPNLMBTNRU",\n "expirationTimestamp": "2023-02-06T12:43:34.634467Z",\n "policyName": "enterprises/LC00y54m79/policies/policy1",\n "qrCode": "{\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME\\":\\"com.google.android.apps.work.clouddpc/.receivers.CloudDeviceAdminReceiver\\",\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM\\":\\"I5YvS0O5hXY46mb01BlRjq4oJJGs2kuUcHvVkAPEXlg\\",\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION\\":\\"https://play.google.com/managed/downloadManagingApp?identifier=setup\\",\\"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE\\":{\\"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN\\":\\"ZBNWPOWHBQUPNLMBTNRU\\"}}"\n}
It is the default Google example and it does not contains my application, instead, it contains Google's official example app.
What am I doing here wrong?
EDIT:
I have syntax error with double quotes.
EDIT 2:
Also tried with starting and ending single quotes like:
'{"android.app.extra (...)
Also tried with starting and ending with triple quotes like in Google's previous example like here:
But still no luck.
The api either returns a syntax error or simple doesn't returns with my app/parameters in the qrCode, instead it replaces to their own example project.
EDIT 3:
Tried like this:
But with no success:
There are two ways to manage devices :
Provision a device with your own DPC : Your DPC is installed (referenced by an URL in the QR code). It fetches policies from your servers and applies them as a profile / device owner, without using any Google API (Android only).
Manage devices using Google Play EMM API. It is basically Google's layer on top of the Android API (but often called Android Management API, which is a bit confusing) : Your EMM console send policies to Google's servers. They are applied on the devices by Google's own DPC.
You are trying to mix the two approaches. It is no longer possible :
Android Enterprise is no longer accepting new registrations for custom device policy controllers (DPC) using the Google Play EMM API.
All new EMM solutions should now use Android Management API, which comes with its own DPC provided by Google.
The Google DPC is the com.google.android.apps.work.clouddpc you are seeing in the generated QR code.
If you want to use you own DPC, you need to use the json containing the android.app.extra.PROVISIONING* keys directly, without wrapping it in a Google token.
The content looks fine except the SSID has to be quoted, and the signature hash should not be percent encoded :
{
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.tmp.app.admin/.AdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://myurl-stuff.com/link_part/my_app.apk",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "MUQ6NEQ6MDQ6NTY6M0E6ODA6Mzg6NEY6NUM6ODI6Qzk6NUY6MkM6QjA6RTk6RDc6QTM6RjI6NDg6NTA6QTQ6RjY6QTA6RjM6MTA6NUM6MzI6NkY6QkU6NUI6M0E6Qzk=",
"android.app.extra.PROVISIONING_SKIP_ENCRYPTION": false,
"android.app.extra.PROVISIONING_WIFI_PASSWORD": "my_wifi_password",
"android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE": "WPA",
"android.app.extra.PROVISIONING_WIFI_SSID": "\"MY_WIFI_SSID\""
}
You just have to generate a QR code containing this content (with any generator), and scan it with the device.
Unfortunately the provisioning process is not forgiving. If something is wrong, the device shows a "Provisionning failed" error message without any clue. You have to triple check everything.
I'm trying to create a google sheets document via script, and I'm using the execution API example google provides here:
https://developers.google.com/apps-script/guides/rest/quickstart/android
The only change I've made was a line on the script:
function getFoldersUnderRoot() {
var sheet = SpreadsheetApp.create("MySheet"); //This line.
var root = DriveApp.getRootFolder();
var folders = root.getFolders();
var folderSet = {};
while (folders.hasNext()) {
var folder = folders.next();
folderSet[folder.getId()] = folder.getName();
}
return folderSet;
}
But, even though i can run the code correctly, it just doesnt create the sheet. Maybe some authorization problem? I couldnt find it... Id thank you so much for your help... I really need this to my project.
Based from this guidelines, before using the API you need to do the following to meet the above requirements:
Create an Apps Script project to call, with the functions you want to use. The API can also be used to call existing scripts that were created for other projects. Open the project in the Apps Script editor.
Deploy the script project for execution by selecting Publish > Deploy as API executable. Choose a version (or create a new one) and who has access, then click Deploy. The new dialog that opens shows your script's ID, listed under "Current API ID". Make note of this ID — you need to enter it into the application code so that the API knows which script to call. If you need to find it again later, select Publish > Deploy as API executable in the code editor to see it.
Choose a Cloud Platform project and ensure both the calling application and the target script share it. If you use the script's default Cloud Platform project, the calling application should use that project to set up its OAuth credentials. This requires you to have access to the default Cloud Platform project, which may not be the case if the script resides in Team Drive. If you are using a new or existing Cloud Platform Project, you need to switch the Apps Script project to use it if you have not done so already.
Enable the Google Apps Script Execution API in the Cloud Platform project. You can find directions for doing this in the Execution API Java Quickstart.
Create a valid Client ID and client secret for the application in the Cloud Platform project. This is covered in the Execution API Java Quickstart.
In the application code, generate an OAuth access token for the API call. This is not a token the API itself uses, but rather one the script requires. The token must be built using the Client ID and the scopes from the script (in the editor, under File > Project properties > Scopes). This also requires prompting the user to authorize the script. The Google client libraries, while not strictly necessary, can greatly assist in handling OAuth for the application.
Hope this helps.
Hi (i'm new to this so you'll need to forgive me)
My end goal is to be able to grab an attribute from Microsoft azure active directory for use in my app. The issue being that while i have done a fair amount of research i'm still at a loss of how to achieve my end result.
I have found that Microsoft has an API of sorts that allows authentication with azure AD but i'm unable to find any information as to how i query an attribute.
Possible solutions I've looked into:
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-devquickstarts-android (Microsoft's android AD API)
Using Java to find simple Active Directory Information (this isn't a possible solution as i need azure integration as the AD server isn't outward facing).
I'm sure that the solution to this isn't a complex one but i would be grateful if someone could point me in the right direction. I don't have much experience with AD which is why i'm struggling here.
You could learn how to integrate Azure AD into an Android app from here . You could call Microsoft Graph API or Azure AD Graph API to access AAD resource :
To call Microsoft Graph API/Azure AD Graph API from Android Native Client application , In Settings blade of that app in azure portal, select Required Permissions and select Add. Locate and select Windows Azure Active Directory(Azure AD graph api )/Microsoft Graph(microsoft graph api) , add the appropriate permissions under Delegated Permissions .
To get access token With ADAL for android :
mContext.acquireToken(MainActivity.this, resource, clientId, redirect, user_loginhint, PromptBehavior.Auto, "", callback);
resource is required and is the resource you're trying to access.So you need to set that value to "https://graph.windows.net" if you want to call Azure AD graph api , and "https://graph.microsoft.com" if you want to call Microsoft Graph Api.
I need to verify the spam score of mobile numbers using Truecaller API .I found documentation here . In the API URL , I need to send a APPKEY , But how to get that ? there is no registration page for Truecaller API .
https://api.truecaller.com/v1.0/search.json?userKey=APPKEY&phone=NUMBER
Any help will be appreciated...
You should Read this Document for Name Search API
it Says that....
The one thing to keep in mind is that all requests to our API require
authentication. For that, you will need to use a User Key (userKey)
along with your requests. These access details basically associate,
your server, script or program with a specific application. All
requests to the API must be made over SSL (https:// not http://).
It means you have registered Truecaller developer account then Do Login and get your Access Key(USER KEY) and pass it everytime you request to access API..
But I Think Truecaller API is not accessible for public users...
Read This Article for More Details : http://www.3scale.net/2013/05/truecaller-api-search-among-over-600-million-phone-numbers-worldwide/
Why don't you try this?
callerpy
Here is the explanation from the developer:
Truecaller Name Retriever.
Since my request for the API was rejected, I commenced using python parsing libraries.
Callerpy emulates the process one would encounter if using a web-browser.
I tried it, and it works like a charm from the command line.
I need to write an Android application that allows a user to connect to multiple social networking sites like MySpace, LinkedIn, FaceBook etc. and fetch friends list.
I know that most of these applications have Java libraries or functionalities exposed as REST based WebServices. But since there is a lot of variety and disparity in the ways that these libaries are written or service that can be consumed, is there any single, integrated service or middleware component that I can use to provide a unified interface in my mobile application?
What would be the best way to go about writing such an application? Any links or pointers to tutorials and documents would be helpful.
Thanks.
Well, that pretty much depends on the service APIs exposed by these sites. If they're RESTful, it would be easy and straight forward to write the API accessors yourself using the Apache HttpClient implementation shipped with Android.
If you want to make your life easier you may want to look at Droid-Fu's HTTP abstractions, and maybe Signpost, if you require OAuth message signing (which you need for many popular sites like Netflix, LinkedIn, Twitter, ...).
Here is some code that fetches mentions from Twitter using these two libraries:
// configure an OAuthConsumer with Twitter credentials
oauthConsumer.setTokenWithSecret(accessToken, tokenSecret);
// get Twitter mentions for the user identified by accessToken
String endpointUrl = "http://twitter.com/statuses/mentions.xml?since_id=12345";
BetterHttpResponse response = BetterHttp.get(endpointUrl).expecting(200, 404).signed(oauthConsumer).send();
if (response.getStatusCode() == 200) {
... // consume response
}
That stuff worked pretty well for me with the Qype API.
I'm also working on similar project. I'm planning to use some of the excellent framework
an open source api for all social networking site except Facebook - http://wiki.opensocial.org/index.php?title=Main_Page
opensocial for Java Client - http://code.google.com/p/opensocial-java-client/ [Android]
[This is the Open Source FaceBook API for Android]3 - https://github.com/facebook/facebook-android-sdk
the most useful Twitter API - http://twitter4j.org/en/index.html
one of the most popular Twitter API - http://www.winterwell.com/software/jtwitter.php
And this link contains some of the excellent project for social network based android app - http://code.google.com/android/adc/gallery_social_networking.html
Cheers
-Neo