CodeIgniter

Using dropbox api/access dropbox files

1)Create account on dropbox.com and find secret and key.2)Download files from

http://fabi.me/en/php-projects/dropphp-dropbox-api-client/comment-page-1/

3)Set the below in sample.php

$dropbox = new DropboxClient(array(
‘app_key’ => “ztjdoqcp6fokpdg”,
‘app_secret’ => “1zcrmy0eja21lcl”,
‘app_full_access’ => true,
),’en’);

4)Create folder tokens in the downloaded folder if it is not there.

5)The output looks like

loaded access token:

Account:
stdClass Object
(
[referral_link] => http://db.tt/fnZNU4dH
[display_name] => pardeep poria
[uid] => 209317516
[country] => IN
[quota_info] => stdClass Object
(
[shared] => 0
[quota] => 2147483648
[normal] => 498318
)

[email] =>
)

Files:
Array
(
[0] => Getting Started.pdf
[1] => test_download_Getting Started.pdf
)

Meta data of /Getting Started.pdf:
stdClass Object
(
[revision] => 1
[rev] => 113bbff14
[thumb_exists] =>
[bytes] => 249159
[modified] => Mon, 02 Sep 2013 05:20:04 +0000
[client_mtime] => Mon, 02 Sep 2013 05:20:04 +0000
[path] => /Getting Started.pdf
[is_dir] =>
[icon] => page_white_acrobat
[root] => dropbox
[mime_type] => application/pdf
[size] => 243.3 KB
)

Downloading /Getting Started.pdf:
stdClass Object
(
[revision] => 1
[rev] => 113bbff14
[thumb_exists] =>
[bytes] => 249159
[modified] => Mon, 02 Sep 2013 05:20:04 +0000
[client_mtime] => Mon, 02 Sep 2013 05:20:04 +0000
[path] => /Getting Started.pdf
[is_dir] =>
[icon] => page_white_acrobat
[root] => dropbox
[mime_type] => application/pdf
[size] => 243.3 KB
)

Uploading test_download_Getting Started.pdf:
stdClass Object
(
[revision] => 2
[rev] => 213bbff14
[thumb_exists] =>
[bytes] => 249159
[modified] => Mon, 02 Sep 2013 11:42:01 +0000
[client_mtime] => Mon, 02 Sep 2013 11:42:01 +0000
[path] => /test_download_Getting Started.pdf
[is_dir] =>
[icon] => page_white_acrobat
[root] => dropbox
[mime_type] => application/pdf
[size] => 243.3 KB
)

done!

Revisions of test_download_Getting Started.pdf:
Array
(
[0] => stdClass Object
(
[revision] => 2
[rev] => 213bbff14
[thumb_exists] =>
[bytes] => 249159
[modified] => Mon, 02 Sep 2013 11:42:01 +0000
[client_mtime] => Mon, 02 Sep 2013 11:42:01 +0000
[path] => /test_download_Getting Started.pdf
[is_dir] =>
[icon] => page_white_acrobat
[root] => dropbox
[mime_type] => application/pdf
[size] => 243.3 KB
)

)

Searching for JPG files:
Nothing found.

Advertisements

scrapping data from a webpage using php,curl and dom object:inesrt into database

<?php
set_time_limit(0);
require_once(‘simple_html_dom.php’);
    // Defining the basic cURL function
    function curl($url) {
        $ch = curl_init();  // Initialising cURL
        curl_setopt($ch, CURLOPT_URL, $url);    // Setting cURL’s URL option with the $url variable passed into the function
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL’s option to return the webpage data
        $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
        curl_close($ch);    // Closing cURL
        return $data;   // Returning the data from the function
    }
    $scraped_website = curl(“http://www.yellowpages.com/los-angeles-ca/doctors?g=los+angeles%2Cca&#8221;);
    
    $doc = new DOMDocument();
  $data=@$doc->loadHTML($scraped_website);
  //print_r($data);
  $achr=$doc->getElementById(‘search-results’);
 
 // echo “<pre>”;
// print_r($achr);
$xpath = new DomXpath($doc);
$div = $xpath->query(‘//*[@class=”street-address”]’);
 for ($i = $div->length – 1; $i > -1; $i–) {
        $result[] = $div->item($i)->textContent;

    }

   // echo “<pre>”;
    //print_r($result);
    
$di = $xpath->query(‘//*[@class=”business-phone phone”]’);
 for ($i = $di->length – 1; $i > -1; $i–) {
        $re[] = $di->item($i)->textContent;
    }

   // echo “<pre>”;
    //print_r($re);    
    
$ca = $xpath->query(‘//*[@class=”city-state”]’);
 for ($i = $ca->length – 1; $i > -1; $i–) {
        $c[] = $ca->item($i)->textContent;
    }

   // echo “<pre>”;
   // print_r($c);
    
$tit = $xpath->query(‘//*[@class=”srp-business-name”]’);
 for ($i = $tit->length – 1; $i > -1; $i–) {
        $t[] = $tit->item($i)->textContent;
    }

    //echo “<pre>”;
    print_r($t);
    
$conn=mysql_connect(“localhost”,”root”,””);
mysql_select_db(‘scrapping’,$conn);
for($i=0;$i<count($t); $i++)
{
$query=”Insert into search_results values(”,'”.addslashes($result[$i]).”‘,'”.addslashes($re[$i]).”‘,'”.addslashes($c[$i]).”‘,'”.addslashes($t[$i]).”‘)”;
mysql_query($query) or die(mysql_error());
}
    exit();
?>

Paypal direct payment method

1.firstly you shoud have paypal account to use the payment method
2.Then you need credentials of credit card from the customer so that he can pay
$api_version = ‘98.0’;
$api_endpoint = ‘https://api-3t.sandbox.paypal.com/nvp&#8217;;
$api_username = ”;
$api_password = ”;
$api_signature =”;
// Store request params in an array
$request_params = array
(
‘METHOD’ => ‘DoDirectPayment’,
‘USER’ => $api_username,
‘PWD’ => $api_password,
‘SIGNATURE’ => $api_signature,
‘VERSION’ => $api_version,
‘PAYMENTACTION’ => ‘Sale’,
‘IPADDRESS’ => $_SERVER[‘REMOTE_ADDR’],
‘CREDITCARDTYPE’ => $ctype,
‘ACCT’ => $cnumber,
‘EXPDATE’ => $e,
‘CVV2’ => $cvv,
‘FIRSTNAME’ => $fname,
‘LASTNAME’ => ‘Testerson’,
‘STREET’ => ‘707 W. Bay Drive’,
‘CITY’ => ‘Largo’,
‘STATE’ => ‘FL’,
‘COUNTRYCODE’ => ‘US’,
‘ZIP’ => $zip,
‘AMT’ => $amount,
‘CURRENCYCODE’ => ‘USD’,
‘DESC’ => ‘Testing Payments Pro’
);

// Loop through $request_params array to generate the NVP string.
$nvp_string = ”;
foreach($request_params as $var=>$val)
{
$nvp_string .= ‘&’.$var.’=’.urlencode($val);
}

// Send NVP string to PayPal and store response
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 100);
curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);

$result = curl_exec($curl);

curl_close($curl);

//echo $result.'<br /><br/>’;
parse_str($result, $arr); //this will convert the response url to array
$data[‘result’]=$arr;
$data[‘file’]=”/thankyou”;
//$this->load->view(‘content’,$data);

}