login community faq

I try to get this tutorial to work:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
function post_simple_message() {
  $request =
    new HttpRequest('https://api.mailgun.net/v2/samples.mailgun.org/messages',
                    HttpRequest::METH_POST);
  $auth = base64_encode('api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
  $request->setHeaders(array('Authorization' => 'Basic '.$auth));
  $request
    ->setPostFields(array('from' => 'Excited User'.
                          ' <Excited User <me@samples.mailgun.org>>',
                          'to' => 'sergeyo@profista.com, serobnic@mail.ru',
                          'subject' => 'Hello',
                          'text' => 'Testing some Mailgun awesomness!'
                          ));
  $request->send();
  return $request;
}

Unfortunately that produces:

1
Fatal error: Class 'HttpRequest' not found in index.php on line 2not found in index.php on line 2

As suggested here I tried adding a php.ini to my webapp containing:

1
2
extension = php_http.dll   
extension = pecl_http.dll

I also checked with phpinfo that my php.ini is parsed.

Any more ideas?

asked Mar 03 '12 at 07:11

ampelmann's gravatar image

ampelmann
2519


Hi,

You need to install the pecl_http PHP extension first. Here's the procedure to install it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mkdir ~/pecl_install
cd ~/pecl_install
wget http://pecl.php.net/get/pecl_http-1.7.1.tgz
tar zxf pecl_http-1.7.1.tgz
cd pecl_http-1.7.1
phpize53
./configure --with-php-config=/usr/local/bin/php53-config
make
mkdir ~/php53-exts
cp modules/http.so ~/php53-exts/
ln -s /usr/local/lib/php53/extensions/no-debug-non-zts-20090626/* ~/php53-exts/
echo "extension_dir = $HOME/php53-exts" >> ~/webapps/<appname>/php.ini
echo "extension = http.so" >> ~/webapps/<appname>/php.ini

You should then be able to use the HttpRequest class.

answered Mar 03 '12 at 07:44

todork's gravatar image

todork
10964

Awesome! Thanks for the quick help as always. You guys rock.

(Mar 03 '12 at 13:34) ampelmann ampelmann's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×146

Asked: Mar 03 '12 at 07:11

Seen: 3,363 times

Last updated: Mar 03 '12 at 13:34

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited