[bd] API

[bd] API 1.6.3

No permission to download
If you are interested in one particular forum, for example the "Chatting" one, forum_id=13, you can go to http://xfrocks.com/api/threads/?forum_id=13 to see threads of that forum (the links section contains some other links like permalink to the resource, link to get sub-forums of a forum, etc.)

If you go to http://xfrocks.com/api/threads/?forum_id=13, you can see the list of threads in "Chatting" forum. Currently there is only one thread but the system supports pages if there are many threads.

How do I translate that back into a custom xf page using the normal templates?
 
Ok, it took a long time for that query to work.....and now the API installed.

But I cannot create a client...it seems. See enclosed error.

I set the permissions for BOTH me personally (my username) and for Administrative, which I obviously am if I am in the ACP.

apino.webp
 
Ok, I appreciate your help......maybe I will eventually get this working!

So, I created a client on the front end....at the MASTER site.

I copied those keys to the SLAVE site.

The MASTER API config has the name and description filled in, and the redirect URI to be slavesite.com/xenforo

The SLAVE Consumer API has as a provider the url
mastersite.com/xenforo/api

auto-register disabled, as I want the user to have to take an action rather than being immediately signed up.

Is that right so far?

Given those settings, when I go to the SLAVE site in a new browser (not logged in anywhere), I see a screen like this:
Screen Shot 2013-05-02 at 12.59.43 PM.webp

But hitting the Login with Hearth.com button brings me to an error page at hearth.com.....

My first questions is whether any actual permissions on the master end have to be set for the regular user groups?

Other than that, please inform if I have the basic settings pointing in the right direction!
 
Also, the field names are a bit confusing since they don't match.

Am I correct in assuming that:
Master Slave
API Key = Client ID
API Secret = Client Secret
 
Ok, I appreciate your help......maybe I will eventually get this working!

So, I created a client on the front end....at the MASTER site.

I copied those keys to the SLAVE site.

The MASTER API config has the name and description filled in, and the redirect URI to be slavesite.com/xenforo

The SLAVE Consumer API has as a provider the url
mastersite.com/xenforo/api

auto-register disabled, as I want the user to have to take an action rather than being immediately signed up.

Is that right so far?

Given those settings, when I go to the SLAVE site in a new browser (not logged in anywhere), I see a screen like this:
View attachment 45528

But hitting the Login with Hearth.com button brings me to an error page at hearth.com.....

My first questions is whether any actual permissions on the master end have to be set for the regular user groups?

Other than that, please inform if I have the basic settings pointing in the right direction!

Yes. Sounds good. What is the error message? Have you copied the .htaccess file from /xenforo into /xenforo/api?
 
I did copy the .htaccess file from the master XF to master api directory.

On the consumer API site, it's a little confusing as to how you are supposed to login (with master creds)

Are you supposed to fill in the XF name and/or pw, or just hit the button what says "login with master-site" and THEN be promoted for the username and pw?

Either way, I get thrown back to slavesite.com/xenforo/register with the URL showing
"http://droneflyers.com/talk/register/external?provider=0489b&error=redirect_uri_mismatch"
and XF showing an error of
"DroneFlyers.com Forums - Error
An error occurred while connecting with Hearth.com. Please try again later."
Screen Shot 2013-05-02 at 9.11.51 PM.webp
I will PM you with a login name and PW...so you can try it yourself!
 
I did copy the .htaccess file from the master XF to master api directory.

On the consumer API site, it's a little confusing as to how you are supposed to login (with master creds)

Are you supposed to fill in the XF name and/or pw, or just hit the button what says "login with master-site" and THEN be promoted for the username and pw?

Either way, I get thrown back to slavesite.com/xenforo/register with the URL showing
"http://droneflyers.com/talk/register/external?provider=0489b&error=redirect_uri_mismatch"
and XF showing an error of
"DroneFlyers.com Forums - Error
An error occurred while connecting with Hearth.com. Please try again later."
View attachment 45547
I will PM you with a login name and PW...so you can try it yourself!

Sorry the add-ons make it a hard time for you. Anyway, the error is "redirect_uri_mismatch" so maybe there are differences between your slave site (droneflyers.com) and the Redirect URI of the client on your master site (heart.com).
 
Well, I think I am lucky now!

It started working.....or at least worked on one account! I will test!

Just so everyone else (and I) are clear on this, if the slave site is slavesite.com/xenforo and the master is mastersite.com/xenforo, then the redirect URL on the master site needs to be http://slavesite.com/xenforo ?

Thanks so much for your help!
If I get this working I will gladly write some docs and also offer some suggestions.

Thanks again!
 
That's correct. The redirect URI is used to verify the origin of the authentication request. If some other website other than the registered slavesite.com used the same client credentials, it will be denied.

And yes, I planned to write documents but haven't got time yet :(
 
This seems to work well for authorizing a user from another (slave) XF site - and I imagine that other developers could extend it to allow XF to share login with mediawikis, wordpress, etc.

As a short note on installation and setup...given your two sites, master and slave...
1. Install this add-on on the master - add-on installation is just like other add-ons.
2. Move a copy of your XF directory .htaccess to the mastersite/xenforo/api directory.
3. Set permissions in the ACP so your username is allowed to create API clients - see enclosed
Screen Shot 2013-05-04 at 9.56.05 AM.webp
4. Create a client - this is a little tricky because it seems as if you should do so in the ACP, but that doesn't seem to work! Xfrocks said to create it by going to this URL:
http://www.mastersite.com/xenforo/account/api - see thumbnail - notice the API Access item in the left menu and the API screen being shown with "create new client".
apiclient.webp
5. The client is easy enough to create - just give it a name and description (anything), but the redirect URI should be back to the OTHER (slave) site XF installations - that is slavesite.com/xenforo or whatever your URL is. The API will automatically create your secret keys.
Screen Shot 2013-05-04 at 10.01.56 AM.webp
6. You are now finished with the master installation! The next step is to install the OTHER [bd] add-on, called "Consumer API" on the slave site. This also installs just like any other add-on
Once installed, you will find the setup in the ACP "options" - you need to specify at your master site as a "provider" of login information. This is easy enough, as there are four fields
Provider Name - enter something that tells you that it is the master site
Provider API URL - this should be entered as in the sample given in the add-on:
http://www.mastersite.com/xenforo/api
ID and Secret - these need to be copied from your master where you "created a client"....
You may want to check the box that says "Bypass Registration Active Check"....

That's it! Now, when a new user enters the login screen at slavesite.com/xenforo/login (or any of the Ajax variations), they will see a button or link which says "login with mastersite.com" - and by following that, they should be able to login to the slave site after approving the remote login.

Note - as Xfrocks has mentioned, this does not copy a password over to the new site - it is like facebook in that regards. But it does copy the email and if the user ever wants a full login (not using this add-on) to the new slavesite.com, they can get themselves mailed a password...and reset it from there.

I hope this helps someone!
 
This seems to work well for authorizing a user from another (slave) XF site - and I imagine that other developers could extend it to allow XF to share login with mediawikis, wordpress, etc.
...
I hope this helps someone!


Very informative, thank you!
 
xfrocks updated [bd] API with a new update entry:

Major update with new features

1.0 (23-05-2013)
1.0/1 added GET /posts/:postId/likes to get like, POST to like, DELETE to unlike
1.0/2 added common parameters `fields_include`, `fields_exclude` to filter data
1.0/3 added `attachments` to post data, POST /threads/attachment and POST /posts/attachment to upload attachment to thread or post
1.0/4 added common parameter `order` to.. order
1.0/5 added logging
1.0/6 added POST /users to create new user
1.0/7 added POST /users/:userId/avatar to upload avatar, DELETE...

Read the rest of this update entry...
 
Hi, could you provide an example authorization? I'm looking to build an automatic poster in Java (command is run in Minecraft, creates a new thread with information).

Thanks!
 
Top Bottom