Y星人の工作語錄

別理我, 我只是一個愛發勞騷的Y星人

1月
27

curl + proxy + ssl + WSDL(nusoap)

Posted by YuanYuan under php

if you want to using WSDL(Web Services Description Language)service, in PHP, you need nusoap, easy to use.

client1 form nusoap example.

  1. <?php
  2. /*
  3. *    $Id: client1.php,v 1.3 2007/11/06 14:48:24 snichol Exp $
  4. *
  5. *    Client sample that should get a fault response.
  6. *
  7. *    Service: SOAP endpoint
  8. *    Payload: rpc/encoded
  9. *    Transport: http
  10. *    Authentication: none
  11. */
  12. require_once('../lib/nusoap.php');
  13. $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
  14. $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
  15. $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
  16. $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
  17. $useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
  18. $client = new nusoap_client("http://soap.amazon.com/onca/soap2", false,
  19.                         $proxyhost, $proxyport, $proxyusername, $proxypassword);
  20. $err = $client->getError();
  21. if ($err) {
  22.     echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
  23.     echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
  24.     exit();
  25. }
  26. $client->setUseCurl($useCURL);
  27. // This is an archaic parameter list
  28. $params = array(
  29.     'manufacturer' => "O'Reilly",
  30.     'page'         => '1',
  31.     'mode'         => 'books',
  32.     'tag'          => 'trachtenberg-20',
  33.     'type'         => 'lite',
  34.     'devtag'       => 'Your tag here',
  35.     'sort'         => '+title'
  36. );
  37. $result = $client->call('ManufacturerSearchRequest', $params, 'http://soap.amazon.com', 'http://soap.amazon.com');
  38. if ($client->fault) {
  39.     echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
  40. } else {
  41.     $err = $client->getError();
  42.     if ($err) {
  43.         echo '<h2>Error</h2><pre>' . $err . '</pre>';
  44.     } else {
  45.         echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
  46.     }
  47. }
  48. echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
  49. echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
  50. echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
  51. ?>
1月
27

curl with proxy

Posted by YuanYuan under php

from Using curl to Query Remote Servers

  1. <? 
  2. // Curl Introduction
  3. $ch = curl_init();
  4. curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
  5. curl_setopt($ch, CURLOPT_HEADER, 1);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  7. $data = curl_exec();
  8. curl_close($ch);
  9.  ?> 
  10.  
  11. <? 
  12. //Curl and form data
  13. $phoneNumber = '4045551111';
  14. $message = 'This message was generated by curl and php';
  15. $curlPost = 'pNUMBER='  . urlencode($phoneNumber) . '&MESSAGE=' . urlencode($message) . '&SUBMIT=Send';
  16. $ch = curl_init();
  17. curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/sendSMS.php');
  18. curl_setopt($ch, CURLOPT_HEADER, 1);
  19. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  20. curl_setopt($ch, CURLOPT_POST, 1);
  21. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  22. $data = curl_exec();
  23. curl_close($ch);
  24.  ?> 
  25.  
  26. <? 
  27. //Curl and proxies
  28. $ch = curl_init();
  29. curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
  30. curl_setopt($ch, CURLOPT_HEADER, 1);
  31. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  32. curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
  33. curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080');
  34. curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
  35. $data = curl_exec();
  36. curl_close($ch);
  37.  ?> 
  38.  
  39. //Authenticating with curl
  40. Example 1:
  41. <?
  42. $ch = curl_init();
  43. curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
  44. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  45. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  46. curl_setopt(CURLOPT_USERPWD, '[username]:[password]') 
  47.  
  48. $data = curl_exec();
  49. curl_close($ch);
  50.  ?> 
  51. Example 2:
  52. <? 
  53. $ch = curl_init();
  54. curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
  55. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  56. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  57. curl_setopt(CURLOPT_USERPWD, '[username]:[password]') 
  58.  
  59. $data = curl_exec();
  60. curl_close($ch);
  61.  ?>
12月
18

do you remeber , “The Age of 8BIT”

Posted by YuanYuan under goodies

8BIT world.

yes, do you remember “Karateka” ?

I find “Karateka II“, you can flying kick. cool

 8 BIT website: