Guest User

Untitled

a guest
Aug 4th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <?php
  2. class cURL {
  3.  
  4. var $headers;
  5. var $user_agent;
  6.  
  7. function cURL()
  8. {
  9. $this->headers[] = 'Connection: Keep-Alive';
  10. $this->headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
  11. $this->user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
  12. }
  13.  
  14.  
  15.  
  16. function post($url,$data) {
  17. $process = curl_init($url);
  18. curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
  19. curl_setopt($process, CURLOPT_HEADER, 1);
  20. curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
  21. curl_setopt($process, CURLOPT_TIMEOUT, 30);
  22. curl_setopt($process, CURLOPT_POSTFIELDS, $data);
  23. curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
  24. curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
  25. curl_setopt($process, CURLOPT_POST, 1);
  26. $return = curl_exec($process);
  27. $info = curl_getinfo($process);
  28. curl_close($process);
  29. return $info;
  30. }
  31.  
  32. }
  33.  
  34. $postdata = "
  35. <?xml version="1.0" encoding="utf-8"?>n
  36.  
  37. <rdf:RDF xmlns="http://purl.org/rss/1.0/"
  38. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  39. xmlns:cl="http://www.craigslist.org/about/cl-bulk-ns/1.0">
  40.  
  41. <channel>
  42. <items>
  43. <rdf:li rdf:resource="NYCBrokerHousingSample1"/>
  44. <rdf:li rdf:resource="NYCBrokerHousingSample2"/>
  45. </items>
  46.  
  47. <cl:auth username="****"
  48. password="****"
  49.  
  50. </channel>
  51. <item rdf:about="NYCBrokerHousingSample1">
  52. <cl:category>apa</cl:category>
  53. <cl:area>chi</cl:area>
  54. <cl:subarea>chc</cl:subarea>
  55. <cl:neighborhood>Lakeview</cl:neighborhood>
  56. <cl:housingInfo price="1450"
  57. bedrooms="0"
  58. sqft="600"/>
  59. <cl:replyEmail privacy="C">bulkuser@bulkposterz.net</cl:replyEmail>
  60. <cl:brokerInfo companyName="Joe Sample and Associates"
  61. feeDisclosure="fee disclosure here" />
  62. <title>Spacious Sunny Studio in Upper West Side</title>
  63. <description><![CDATA[
  64. posting body here
  65. ]]></description>
  66. </item>
  67.  
  68.  
  69.  
  70. </rdf:RDF>
  71. ";
  72.  
  73. $cc = new cURL();
  74. $url = 'https://post.craigslist.org/bulk-rss/post';
  75. $output = $cc->post($url,$postdata);
  76.  
  77. //echo $output;
  78.  
  79. print_r($output);
Add Comment
Please, Sign In to add comment