ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having trouble with a PHP API that my company paid to access. We were given the specifications as far as what requests give which response and such, but we have no access to the authentication code. We can access the information by physically typing the requests into a browser, but I am having trouble thinking of a way to do this from a new web site. I know this is a very open question, but as I have little experience in web programming, does anyone have any suggestions?
I have tried this with HttpRequest with no results- will it make a difference to try it with HTTP_Request2? Also, is the code I used correct? (As I said, I'm very new to web coding)
Code:
<html>
<body>
test
<?php
$req = new HttpRequest("<siteURL>", HttpRequest::METH_GET);
$req->send();
echo $req->getResponseBody();
?>
</body>
</html>
EDIT: I should probably mention that I am fairly certain this code is incorrect, as it appears to be breaking when I create the request, rather than when I send it.
What API is that? I mean, request class for HTTP/Request2 is HTTP_Request2? Also, so it doesn't work because? do you have logs? What's the possible return value of send()? Will it say if the request failed? If so, where can you get information about the failure reason?
I'm not sure why, but that code gives me an 'unexpected T_VARIABLE' error. I have checked it six times, and there are no missing semicolons or unbalanced parens/brackets. I can't find any incorrect syntax at all, but I'm still getting that error.
Yeah, I figured there would be more to do once I got that part working, but I wanted to start with getting it to run. And I probably should have seen that as well- I have been working on getting PHP figured out for a couple days now, but I guess I'm not picking it up very quickly.
One step at time.
I don't have that pear library so my help is quite limited at the moment.
I am still not really sure which is your exact problem, it is easy to help if you are very verbose about what is going on and what your exact problem is.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.