Beispiel #1
0
 public function testStoreDelete()
 {
     $data1 = ['name' => time(), 'creative_id' => 60, 'budget' => 500, 'price' => 20, 'start_time' => '2015-08-01 09:40:00', 'end_time' => '2970-01-01 00:00:00', 'fans' => '["1662047260","2977214740"]', 'age[start]' => '8', 'age[end]' => '78', 'gender' => '401', 'location' => '-1', 'device' => '110201', 'network_type[]' => '1204', 'talking_data_url' => 'http://www.baidu.com', 'ge_tui_url' => 'http://www.ba222idu.com', 'customer_id' => 3779606125];
     $result = Curl::post('http://local.app.weibo.com/app/campaigns?_is_ajax=1', $data1, [$this->cookies]);
     echo $result;
     $this->assertEquals(201, Curl::getHttpCode());
     //
     //        $data1 = [
     //            'customer_id' => 0,
     //            '_method' => 'delete'
     //        ];
     //
     //        $result = Curl::post('http://suchong.fst.weibo.com/creatives/5?_is_ajax=1', $data1, [$this->cookies]);
     //        $this->assertEquals(200, Curl::getHttpCode());
     //        echo $result;
     //
     //        $data1 = [
     //            'customer_id' => 0,
     //            '_method' => 'put',
     //            'disable_comment' => 0
     //        ];
     //
     //        $result = Curl::post('http://suchong.fst.weibo.com/creatives/4?_is_ajax=1', $data1, [$this->cookies]);
     //        echo $result;
     //        $this->assertEquals(200, Curl::getHttpCode());
 }
Beispiel #2
0
 public function testToken2()
 {
     $_app_key = '4009338982';
     $_app_secret = 'ffac76a449f5f2ec5a05e14097dcdee5';
     $post_data = array('app_secret' => $_app_secret);
     $retry_count = 3;
     $url = 'http://i2.api.weibo.com/auth/tauth_token.json?source=' . $_app_key;
     while ($retry_count-- > 0) {
         $result = Curl::post($url, $post_data);
         if (Curl::getHttpCode() === 200) {
             break;
         }
     }
     //code返回
     $this->assertEquals(200, Curl::getHttpCode());
 }
         }
         $movie_data['categories'] = array();
         if (count($categories)) {
             foreach ($categories as $category_id => $val) {
                 foreach ($imdb_data['genres'] as $key => $genre) {
                     if (preg_replace("/[^a-z0-9]/", "", strtolower($genre)) == preg_replace("/[^a-z0-9]/", "", strtolower($val['name']))) {
                         $movie_data['categories'][] = $category_id;
                     }
                 }
             }
         }
     }
     if (isset($imdb_data['image'])) {
         $curl = new Curl();
         $image_data = $curl->get($imdb_data['image']);
         if ($image_data && $curl->getHttpCode() >= 200 && $curl->getHttpCode() < 400) {
             $image_name = "movie_" . md5($imdb_data['title'] . $link_data['imdb_id']);
             $handle = fopen("../thumbs/{$image_name}.jpg", "w+");
             fwrite($handle, $image_data);
             fclose($handle);
             $movie_data['thumb'] = $image_name . ".jpg";
         } else {
             $movie_data['thumb'] = "";
         }
     }
 }
 $errors = $movie->validate($movie_data, false, true);
 if (count($errors)) {
     print_r($errors);
     $movie_id = 0;
     $error = "There was a problem adding this movie. Please add it manually";
Beispiel #4
0
require_once "../vars.php";
require_once "../includes/curl.php";
$curl = new Curl();
$show = new Show();
$cache_file = "tv_guide_" . $date . ".txt";
$from_cache = false;
if (file_exists($basepath . "/cachefiles/" . $cache_file)) {
    $data = file_get_contents($basepath . "/cachefiles/" . $cache_file);
    $from_cache = true;
} else {
    $today = date("Ymd");
    $b64 = 'aHR0cDovL2FwaS50cmFrdC50di9jYWxlbmRhci9zaG93cy5qc29uLzUyMWRmZjU0NTQyM2RiNGE1NmUxNzUwMTNkYmFkNGFiLw==';
    $request = '' . base64_decode($b64) . urlencode($today) . '/1/';
    $data = $curl->get($request);
}
if ($from_cache || $curl->getHttpCode() >= 200 && $curl->getHttpCode() < 400) {
    if (!$from_cache && is_writable($basepath . "/cachefiles/")) {
        @file_put_contents($basepath . "/cachefiles/" . $cache_file, $data);
    }
    $data = json_decode($data, true);
    if (isset($data['0'])) {
        foreach ($data['0']['episodes'] as $key => $event) {
            $events[$key]['episode_number'] = str_replace(array("#season#", "#episode#"), array(str_pad($event['episode'][season], 2, 0, STR_PAD_LEFT), str_pad($event['episode'][number], 2, 0, STR_PAD_LEFT)), $lang['tv_guide_episode_number']);
            $show_data = $show->getShowByImdb($events[$key]['imdb_id'], $language);
            if (!count($show_data)) {
                // echo $show_data;
                $events[$key]['imdb_id'] = $event['show'][imdb_id];
                $events[$key]['country'] = $event['show'][country];
                $events[$key]['series'] = $event['show'][title];
                $events[$key]['network'] = $event['show'][network];
                $events[$key]['air_time'] = $event['show'][air_time];
Beispiel #5
0
 public function getStatus()
 {
     return $this->curl->getHttpCode();
 }
     <div class="row-fluid" style="margin-top:0px;">
         <?php 
 $allplugins = $plugins->getAllPlugins();
 $plugin_names = array();
 foreach ($allplugins as $key => $val) {
     $plugin_names[] = $val['dirname'];
 }
 $current_version = $settings->getSetting("version", false);
 if (empty($current_version)) {
     $current_version = "2.0";
 }
 $error = false;
 $should_upgrade = true;
 if (!$error) {
     $version = $curl->get($updater->api_path . "?method=getVersion&key=" . $license_key);
     if ($curl->getHttpCode() >= 200 && $curl->getHttpCode() < 400) {
         $version = json_decode($version, true);
         if (!isset($version['version'])) {
             $latest_version = $current_version;
         } else {
             $latest_version = $version['version'];
         }
     } else {
         $updater->upgradeLog("Checking latest version...", false, "API down, try again later");
         $error = true;
     }
 }
 if (!$error) {
     if ($latest_version <= $current_version) {
         $should_upgrade = false;
         $updater->upgradeLog("Your installation is up to date", true, "Version: " . $current_version);
Beispiel #7
0
<?php

if (isset($_GET['keyword']) && $_GET['keyword']) {
    $keyword = $_GET['keyword'];
} elseif (isset($argv[1]) && $argv[1]) {
    $keyword = $argv[1];
} else {
    die("usage: php {$argv[0]} [keyword]\n");
}
require_once "../curl.class.php";
$curl = new Curl();
$page = $curl->get("http://www.ebay.com/sch/i.html?_trksid=p2050601.m570.l1313&_nkw=" . urlencode($keyword) . "&_sacat=0&_from=R40");
if ($page && $curl->getHttpCode() >= 200 && $curl->getHttpCode() < 400) {
    $dom = new DOMDocument();
    @$dom->loadHTML($page);
    $tables = $dom->getElementsByTagName('table');
    for ($i = 0; $i < $tables->length; $i++) {
        if ($tables->item($i)->getAttribute("itemtype") != "http://schema.org/Offer") {
            continue;
        }
        $h4s = $tables->item($i)->getElementsByTagName('h4');
        if (!$h4s->length) {
            continue;
        }
        $links = $h4s->item(0)->getElementsByTagName('a');
        if (!$links->length) {
            continue;
        }
        $item_title = $links->item(0)->textContent;
        $item_url = $links->item(0)->getAttribute("href");
        print $item_title . "\t" . $item_url . "\n";