Advertisement:

Author Topic: SMF 2.0 "REST" API  (Read 137424 times)

Offline hebelehubele

  • Semi-Newbie
  • *
  • Posts: 16
Re: SMF 2.0 "REST" API
« Reply #20 on: February 14, 2013, 09:02:09 AM »
ummm...   If I read it correctly, you are doing the exact opposite. You are attempting to get the SMF user data, not set it...

Actually, I attempted to get user info that understand user was logged in... Can you help me for this api ? How can I send data to login action ? The data stored in SMF member table in DB

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,115
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #21 on: February 14, 2013, 09:35:32 AM »
wait... you seem to be talking at cross purposes here.

HWich is th eprimary system?

Do you have an outside system which you want to pass data TO SMF and control the interface?
or
Do you have an outside system which you want to accept data FROM SMF and allow SMF to control the interface?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline hebelehubele

  • Semi-Newbie
  • *
  • Posts: 16
Re: SMF 2.0 "REST" API
« Reply #22 on: February 14, 2013, 10:04:22 AM »
First one.

I have an outside system. If I login into outside system, login to SMF too.

Offline hebelehubele

  • Semi-Newbie
  • *
  • Posts: 16
Re: SMF 2.0 "REST" API
« Reply #23 on: February 15, 2013, 03:47:52 AM »
Ok I separeted my logins. I send data to smf with iFrame and it login itself. After I register my own session. But SMF login system F.ck my own session.  >:(

How to change smf Session.Save_Path... I think , if I change this I can separate my sessions.

Offline hebelehubele

  • Semi-Newbie
  • *
  • Posts: 16
Re: SMF 2.0 "REST" API
« Reply #24 on: February 15, 2013, 04:45:51 AM »
How to logout from SMF with outside link ?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,045
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #25 on: February 15, 2013, 07:41:11 AM »
Why not just have *one* login system and be done with it? Much lighter on the system, uses less bandwidth too.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline hebelehubele

  • Semi-Newbie
  • *
  • Posts: 16
Re: SMF 2.0 "REST" API
« Reply #26 on: February 15, 2013, 07:50:08 AM »
Because , SMF is later integrate to our CRM software.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,115
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #27 on: February 15, 2013, 09:13:46 AM »
what does that have to do with anything?

This is what I was trying to get at...   Arantor just put it better.   This entire design should be setting *ONE* system to handle control and then just pass through data.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline hebelehubele

  • Semi-Newbie
  • *
  • Posts: 16
Re: SMF 2.0 "REST" API
« Reply #28 on: February 16, 2013, 02:46:02 AM »
I already use one login system... Send login data to SMF login in the backend. I passed this issue.

My actual issue is logout from SMF from backend. I don't kill SMF session with session_destroy();

Offline leggendario

  • Newbie
  • *
  • Posts: 3
Re: SMF 2.0 "REST" API
« Reply #29 on: February 20, 2013, 12:31:32 PM »

If you're on the same domain, use the regular API, which will let you login and logout easily.
http://www.simplemachines.org/community/index.php?topic=453008.0
Otherwise I'd recommend examining jquery's smf login method and duplicating that.

I need to login in my test.backend.local and in my test.forum.local
I googled a bit 'around but I could not find anything about this jquery's smf login method
could you give me some info, please?

Offline webgab

  • Newbie
  • *
  • Posts: 2
Re: SMF 2.0 "REST" API
« Reply #30 on: March 13, 2013, 07:01:51 AM »
Hey there,

I'm new to SMF and this API. I'm developing a browsergame in PHP and want to connect SMF with my game. The game is on my local server (game.domain.com) and SMF is on Webhoster (smf.domain.com).
I have one Question.

The login function:
What does 'Will only log them in remotely as cookies cannot be set cross-domain' mean exactly? In gerneral I'm using the same domain, with differnt sub-domains. Can I set cookies when I'm on the same domain (, but differnt sub-domains)?
What does remotely mean? Will the User be redirected to the Forum and then logged in?

Webgab

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,115
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #31 on: March 13, 2013, 07:22:33 AM »
set your smf cookies to be subdomain independent.
set your other program's cookies at the root domain rather than the subdomain.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline webgab

  • Newbie
  • *
  • Posts: 2
Re: SMF 2.0 "REST" API
« Reply #32 on: March 29, 2013, 06:59:35 AM »
Today I wanted to test this out, but I'm doning something horrible wrong  ;D

I uploaded the api and session folder to the smf root. Edited the secret key etc. And then I made a new php data:

Code: [Select]
<?
require_once('lib/SmfRestClient.php');
$secretKey = 'Secret Key here';
$api = new SmfRestClient($secretKey, 'raw');
$api->login_user('webgab');
$result = $api->get_userInfo();
var_dump($result);
?>

I'm always getting a 404 error:

string '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /api/get/userInfo.raw was not found on this server.</p>
</body></html>
' (length=218)


Edit: Got the problem: .htaccess wasn't active :D

But now, the login isn't working. I set the cookies to be independant. When I'm pasting the requested URL into my browser anything works fine. But when i'm calling my API script (sub.domain.com/api.php) it doesnt work. Why?
Do I have to put the api.php on the main domain? (domain.com/api.php)

« Last Edit: March 29, 2013, 09:47:25 AM by webgab »

Offline Taidaishar

  • Newbie
  • *
  • Posts: 6
Re: SMF 2.0 "REST" API
« Reply #33 on: May 16, 2013, 02:06:58 PM »
Why not just have *one* login system and be done with it? Much lighter on the system, uses less bandwidth too.

I have been combing the treads here and I think this is the what I have been looking for.
I would like to have one registration and log on for my website and forum.
my current file structure on my host is:

public (containing index.php [wich is the welcome/login page])
    Home Directory which includes the multiple webpages as well as Forum directory
           Forum directory (the actual SMF forum)

What I would like to do is ensure the webpages in the Home file are not accessible without loggin in and be able to have the members register and/or log on from the welcome page of my website  (opening the home page of my website upon login) using the SMF login/registration system. Then, through the menu bars on each webpage, be able to navigate to the forums and back without an additional log in prompts.

Is this possible and if so how would I set this up or where can I find the information?
Please let me know if more info is needed.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,115
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #34 on: May 16, 2013, 04:33:31 PM »
you don't need the API for that at all.
The API is for joining together two disparate systems.

For what you want to do (use SMF login and regsitration and use smf permissions) then SSI is the best choice (and the simplest)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline vart001

  • Semi-Newbie
  • *
  • Posts: 60
    • portal hacker
Re: SMF 2.0 "REST" API
« Reply #35 on: August 06, 2013, 03:12:25 PM »
I can use the API for this?:
forum: www.domain1.com
website at: www.domain2.com

API: domain2.com need that can do login, restrict access to pages for members only, register etc..

Both domains are on the same server and can share the same database.
You can use the API for this purpose?

Thank you.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,115
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #36 on: August 06, 2013, 03:33:19 PM »
no.

Logins will NOT transfer across domains... for very good reasons. the login sets a session and a cookie. If the cookie was set for a different domain, it would trigger all sorts of virus warnings in modern browsers.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline vart001

  • Semi-Newbie
  • *
  • Posts: 60
    • portal hacker
Re: SMF 2.0 "REST" API
« Reply #37 on: August 06, 2013, 05:01:20 PM »
thank you very much.
I understand that the transfer of cookies is not possible for security reasons.

I want 2 websites using the same database and same user system, I think I'll have to abandon my project.
thanks

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,115
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #38 on: August 06, 2013, 05:09:57 PM »
if they are on the same server, you can use feline's subforum mod...
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline seekaprice

  • Newbie
  • *
  • Posts: 1
Re: SMF 2.0 "REST" API
« Reply #39 on: September 18, 2013, 01:51:14 PM »
Does any one know where I can get the api files?