Jump to content

Stargate22

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Stargate22

  1. Hello Guys, I am trying to create a function to add contacts to the yahoo mailbox im stuck at posting the contacts and saving them I need to create function postcontact in order to post and save the on yahoo. How should I do that? public function addcontact() { if (!$this->loggedin) { $this->Error = 'You must be logged in first'; return false; } if (!is_file(ISD_ROOT . '/tmp/camps/' . $this->oferta . '/fromlines.txt')) { $this->Error = 'No fromlines file' . ISD_ROOT . '/tmp/camps/' . $this->oferta . '/fromlines.txt'; return false; } if (!is_file(ISD_ROOT . '/domains.txt')) { $this->Error = 'No domains file'; return false; } $fromlines = @SPUtils::readdata(ISD_ROOT . '/tmp/camps/' . $this->oferta . '/fromlines.txt'); foreach($fromlines as $a=>$b){ $nla = $fromlines[array_rand($fromlines, 1)]; $froms[]=str_replace(' ','.',$nla); } $domains = @SPUtils::readdata(ISD_ROOT . '/domains.txt'); $fromm = str_replace(' ', '.', $nla); foreach ($domains as $k => $l) { foreach($froms as $k=>$v){ $contact_fields[] = array('type' => 'email', 'value' => $v . '@' . trim($l)); } } $fromname = explode(' ', $nla, 2); $contact_fields[] = array('type' => 'name', 'value' => array('givenName' => $fromname[0], 'familyName' => (string )$fromname[1])); $contact = array('fields' => $contact_fields); $data = array('contact' => $contact); $body = json_encode($data); $resp = $this->generatetokens(); parse_str($resp); var_dump($$body); $retarr = postcontact($this->OAuthConsumerKey, $this->OAuthConsumerSecret, $xoauth_yahoo_guid, $oauth_token, $oauth_token_secret, $body, true, true); return true; }
  2. //could not find an attachment option... sorry for spam. o.O <response> <version>0.1</version> <termsofService>http://www.wunderground.com/weather/api/d/terms.html</termsofService> <features> <feature>geolookup</feature> <feature>conditions</feature> </features> <location> <type>CITY</type> <country>US</country> <country_iso3166>US</country_iso3166> <country_name>USA</country_name> <state>NY</state> <city>New York</city> <tz_short>EDT</tz_short> <tz_long>America/New_York</tz_long> <lat>40.75013351</lat> <lon>-73.99700928</lon> <zip>10001</zip> <magic>3</magic> <wmo>99999</wmo> <l>/q/zmw:10001.3.99999</l> <requesturl>US/NY/New_York.html</requesturl> <wuiurl>http://www.wunderground.com/US/NY/New_York.html</wuiurl> <nearby_weather_stations> <airport> <station> <city>Central Park</city> <state>NY</state> <country>US</country> <icao>KNYC</icao> <lat>40.77899933</lat> <lon>-73.96924591</lon> </station> <station> <city>New York Downtown Manhattan/w</city> <state>NY</state> <country>US</country> <icao>KJRB</icao> <lat>40.70121384</lat> <lon>-74.00902557</lon> </station> <station> <city>New York</city> <state>NY</state> <country>US</country> <icao>KLGA</icao> <lat>40.77944565</lat> <lon>-73.88027191</lon> </station> <station> <city>Teterboro</city> <state>NJ</state> <country>US</country> <icao>KTEB</icao> <lat>40.85899353</lat> <lon>-74.05616760</lon> </station> </airport> <pws> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO206</id> <lat>40.748192</lat> <lon>-74.001923</lon> <distance_km>0</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO307</id> <lat>40.745659</lat> <lon>-73.999336</lon> <distance_km>0</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO324</id> <lat>40.744850</lat> <lon>-73.999626</lon> <distance_km>0</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO354</id> <lat>40.752243</lat> <lon>-74.004166</lon> <distance_km>0</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>Hoboken</city> <state>NJ</state> <country>US</country> <id>KNJHOBOK4</id> <lat>40.746616</lat> <lon>-74.004456</lon> <distance_km>0</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO230</id> <lat>40.744087</lat> <lon>-73.990326</lon> <distance_km>0</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO218</id> <lat>40.743759</lat> <lon>-73.986359</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Hell's Kitchen</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO285</id> <lat>40.760880</lat> <lon>-73.999069</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Flatiron</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO118</id> <lat>40.743301</lat> <lon>-73.985466</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Murray Hill</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO71</id> <lat>40.746399</lat> <lon>-73.981598</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Hell's Kitchen</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO200</id> <lat>40.761570</lat> <lon>-73.989952</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown West</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO343</id> <lat>40.762779</lat> <lon>-73.991776</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Lower Manhattan</neighborhood> <city>Hoboken</city> <state>NJ</state> <country>US</country> <id>KNJHOBOK12</id> <lat>40.738083</lat> <lon>-74.004951</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown East</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO91</id> <lat>40.752632</lat> <lon>-73.979225</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO165</id> <lat>40.749748</lat> <lon>-73.978706</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Lower Manhattan</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO275</id> <lat>40.735519</lat> <lon>-73.996330</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Lower Manhattan</neighborhood> <city>Hoboken</city> <state>NJ</state> <country>US</country> <id>KNJHOBOK22</id> <lat>40.734905</lat> <lon>-74.008102</lon> <distance_km>1</distance_km> <distance_mi>1</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO359</id> <lat>40.736454</lat> <lon>-73.982727</lon> <distance_km>1</distance_km> <distance_mi>1</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO193</id> <lat>40.751450</lat> <lon>-73.978241</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Theater District</neighborhood> <city>New York</city> <state>NY</state> <country>US</country> <id>KNYNEWYO168</id> <lat>40.761948</lat> <lon>-73.986061</lon> <distance_km>1</distance_km> <distance_mi>0</distance_mi> </station> <station> <neighborhood>Midtown</neighborhood> <city>Long Island City</city> <state>NY</state> <country>US</country> <id>KNYLONGI7</id> <lat>40.746727</lat> <lon>-73.974274</lon> <distance_km>1</distance_km> <distance_mi>1</distance_mi> </station> </pws> </nearby_weather_stations> </location> <current_observation> <image> <url>http://icons.wxug.com/graphics/wu2/logo_130x80.png</url> <title>Weather Underground</title> <link>http://www.wunderground.com</link> </image> <display_location> <full>New York, NY</full> <city>New York</city> <state>NY</state> <state_name>New York</state_name> <country>US</country> <country_iso3166>US</country_iso3166> <zip>10001</zip> <magic>3</magic> <wmo>99999</wmo> <latitude>40.75013351</latitude> <longitude>-73.99700928</longitude> <elevation>17.00000000</elevation> </display_location> <observation_location> <full>Flatiron, New York, New York</full> <city>Flatiron, New York</city> <state>New York</state> <country>US</country> <country_iso3166>US</country_iso3166> <latitude>40.743301</latitude> <longitude>-73.985466</longitude> <elevation>207 ft</elevation> </observation_location> <estimated> </estimated> <station_id>KNYNEWYO118</station_id> <observation_time>Last Updated on September 22, 5:43 PM EDT</observation_time> <observation_time_rfc822>Tue, 22 Sep 2015 17:43:01 -0400</observation_time_rfc822> <observation_epoch>1442958181</observation_epoch> <local_time_rfc822>Tue, 22 Sep 2015 17:43:02 -0400</local_time_rfc822> <local_epoch>1442958182</local_epoch> <local_tz_short>EDT</local_tz_short> <local_tz_long>America/New_York</local_tz_long> <local_tz_offset>-0400</local_tz_offset> <weather>Overcast</weather> <temperature_string>69.6 F (20.9 C)</temperature_string> <temp_f>69.6</temp_f> <temp_c>20.9</temp_c> <relative_humidity>52%</relative_humidity> <wind_string>Calm</wind_string> <wind_dir>NNE</wind_dir> <wind_degrees>22</wind_degrees> <wind_mph>0.0</wind_mph> <wind_gust_mph>0</wind_gust_mph> <wind_kph>0.0</wind_kph> <wind_gust_kph>0</wind_gust_kph> <pressure_mb>1024</pressure_mb> <pressure_in>30.24</pressure_in> <pressure_trend>-</pressure_trend> <dewpoint_string>51 F (11 C)</dewpoint_string> <dewpoint_f>51</dewpoint_f> <dewpoint_c>11</dewpoint_c> <heat_index_string>NA</heat_index_string> <heat_index_f>NA</heat_index_f> <heat_index_c>NA</heat_index_c> <windchill_string>NA</windchill_string> <windchill_f>NA</windchill_f> <windchill_c>NA</windchill_c> <feelslike_string>69.6 F (20.9 C)</feelslike_string> <feelslike_f>69.6</feelslike_f> <feelslike_c>20.9</feelslike_c> <visibility_mi>10.0</visibility_mi> <visibility_km>16.1</visibility_km> <solarradiation>65</solarradiation> <UV>1.0</UV> <precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string> <precip_1hr_in>0.00</precip_1hr_in> <precip_1hr_metric> 0</precip_1hr_metric> <precip_today_string> in ( mm)</precip_today_string> <precip_today_in></precip_today_in> <precip_today_metric></precip_today_metric> <icon>cloudy</icon> <icon_url>http://icons.wxug.com/i/c/k/cloudy.gif</icon_url> <forecast_url>http://www.wunderground.com/US/NY/New_York.html</forecast_url> <history_url>http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KNYNEWYO118</history_url> <ob_url>http://www.wunderground.com/cgi-bin/findweather/getForecast?query=40.743301,-73.985466</ob_url> </current_observation> </response>
  3. I tried the changes your provided: var_dump($output); prints: array (size=1) 0 => array (size=4) 0 => object(SimpleXMLElement)[9] 1 => object(SimpleXMLElement)[8] 2 => object(SimpleXMLElement)[7] 3 => object(SimpleXMLElement)[10] where $output is $output[] = array($time[0], $temperature[0], $current[0],$wind[0]); while print_r output of the same $output is: Array ( [0] => Array ( [0] => SimpleXMLElement Object ( ) [1] => SimpleXMLElement Object ( ) [2] => SimpleXMLElement Object ( ) [3] => SimpleXMLElement Object ( ) ) ) tried to json econde stil not working.. it only prints when i click on a city that does not exist. is it posible that my array can not be converted to json format? can`t seem to find anything on google about that.
  4. @requinix Thank you for removing the key and for the help! 1. xml is attached (there is location and curent_observation. 2.3. my loop is working.. if i replace the $output and skip the json_encode().. it is working perfectly script is activated when user click on a <li> element from my index. 5.6 Updated my last bit of code and it is printing when i click on a city that does not exist.. but when i click one that does.. it does not print anything.. header('Content-Type: application/json'); echo json_encode($output); ?> 7. removed the <h1> and its working perfectly I think the problem is here... this output does not get printed ...and also no error.. is this line not correct? $output = array($time[0], $temperature[0], $current[0],$wind[0],); Thank you very much for your support!
  5. Hello guys, I have a ajax connection to my json.php file and its not working... do you have any idea what is going on? is it my $output variable is it not convertible to json can it be my ajax?! any help will be greatly appreciated. <?php #$KEY if(isset($_POST['city'])){ $city = $_POST['city']; //checks if variable city is set if not it will be set as default to bcharest #var_dump($city); }else{ $city = 'New York'; } //loads data as simple xml $result = "http://api.wunderground.com/api/KEY/geolookup/conditions/q/us/$city.xml"; $xml = simplexml_load_file($result); #echo htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); $place = $xml->location->city; //gets the city name #ar_dump($place); if(!empty($place)){ //checks if city exits foreach($xml->current_observation as $item){ $current = $item->xpath('weather'); $temperature = $item->xpath('temp_c'); $time = $item->xpath('local_time_rfc822'); // parsing the document in order to get the needed info $wind = $item->xpath('wind_string'); #$wind = array_map( 'strtolower' ,$wind); $humidity = $item->xpath('relative_humidity'); $output = array($time[0], $temperature[0], $current[0],$wind[0],); } }else{ $output = '<h1>No results found, please try a different city.</h1>'; //if variable $place is empty it will print this } header('Content-Type: application/json'); json_encode($output[0]); echo $output[0]; ?> and my ajax: $(document).ready(function() { $('li').click(function(){ var city = $(this).text(); //get the li content as variable city $.ajax({ type : 'POST', //sending data method url : 'json.php', data : {city:city}, //data to be sent dataType: 'json', success : function(data){ $("#result").html(data[0]); } }); }); });
  6. @Barand Yeap, because I did not trimmed them it did not work, I`m Blind o.O Thank you guys for all the help. @Hansford, thank you for the code!
  7. Hello, It prints the array cities like: array (size=268) 0 => string 'Aboed' (length=5) 1 => string ' Ajold' (length=7) 2 => string ' Afed' (length=6) 3 => string ' ... etc Eugir' (length=7) 82 => string ' Eurtici' (length=9) 83 => string ' .. etc foreach ($new as $city) { $findme = "E"; $pos2 = strpos($city, $findme); #if($pos2 !== false){ #echo "<li>$city</li>"; } } ^-> above code prints all cities that start with E... but why is my initial code not workin`?
  8. @requinix if i remove the if and let the print_r it is printing the array like: New York Los Angeles Edinburgh and so on...
  9. Hello guys $myFile = "smt.txt"; $fh = fopen($myFile, 'r'); $all = fread($fh, filesize($myFile)); $cities = explode ("," , $all); foreach ($cities as $city) { if(0 === strpos($city,'E')){ print_r($city); } } I want to print only the strings from the array $cities that start with E , my code does nothing, not an error, nothing.. if i remove the if and let the print it works.. but I need just thous that start with E. Do you guys have any tips? PS: in my array there are a lot of cities that start with E... Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.