Skip to content

Conversation

MeLlamoPablo
Copy link
Contributor

Hello again. I'm still developing my project wich I've uploaded to GitHub (in case you wanted to check it out if you were interested. And don't worry, I'll credit you when it's done :P). This time I needed to pass variables to be retrieved after the user logs in, and the framework currently didn't have support for that. So, I've added it, and I've uploaded it to my fork, in case you wanted to consider merging it. Here's how it works.

The steamlogin() function works as usual. The only change is that you now have to put echo before calling it: the function itself won't echo the button anymore, you have to manually do it. Why? Felxibility. Sometimes you don't need the button to be echoed immediatly, but stored it in a variable to maybe pass it as a parameter to a method. For example, in my script I pass the button as a parameter to the method Modal::__construct(). The class will create a Bootstrap Modal later, and include the button on it. If steamlogin() did echo instead of return I'd need to modify my entire class; this way is much more convenient.

So, any app that ran

steamlogin();

should now run

echo steamlogin();

And now, the most important change. If you want to pass variables to be returned after the login, you'd do the following:

echo steamlogin("foo=1&bar=2");

Notice that you don't have to put any ?s and &s at the beginning.
In that case, you can use $_GET['foo'] and $_GET['bar'] on your login page (set on the settings), and they will be set to 1 and 2, respectively. Assuming that your return URL is http://website.com/index.php, the user will be redirected to http://website.com/index.php?foo=1&bar=2 after loging in successfully on Steam.

One last change: the line session_start() at line 37 on the old file was removed because it's already called at the beginning, so I believe that there's no point on calling it again (In fact, it gives you a warning)

Thanks for your time, and have a nice day!

@BlackCetha
Copy link
Contributor

You can actually use http_build_query(array arguments) to build your parameter list, so you can just provide an array for $additional_parameters.

@MeLlamoPablo
Copy link
Contributor Author

That's true, and more convenient. I didn't think about that. So the way of doing this would be, then:

$vars = http_build_query(array('var1' => 'foo', 'var2' => 'bar'));
echo steamlogin($vars);

@BlackCetha
Copy link
Contributor

Do that inside your function

@MeLlamoPablo
Copy link
Contributor Author

Okay, I've changed it. I've also updated the example file and the readme with the changes.

@BlackCetha
Copy link
Contributor

One last thing, then were done: Its additional, not aditional.
Could you fix that please?

@MeLlamoPablo
Copy link
Contributor Author

Sure thing. English is nor my first language, sorry.

@@ -25,27 +25,53 @@ Add your API-Key from http://steamcommunity.com/dev/apikey

Now in your file add the following at the top:

<?php
```php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a typo, it's the way of telling GitHub wich sintax will you be using for code highlighting

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah thats github formatting, thought it was code and not the readme

SmItH197 added a commit that referenced this pull request Jul 12, 2015
Added support for passing _GET variables upon login
@SmItH197 SmItH197 merged commit 329b19a into SmItH197:master Jul 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants