Wednesday, March 25, 2009
Monday, March 23, 2009
RSS reader IPHONE SDK 2.1
Change
NSString * path = @"http://rss.cnn.com/rss/money_latest.rss";
With
NSString * path = @"Yours";
download the zip here
NSString * path = @"http://rss.cnn.com/rss/money_latest.rss";
With
NSString * path = @"Yours";
download the zip here
Monday, March 16, 2009
Google charts with visualazation via SVG and VML
http://code.google.com/apis/visualization/documentation/gallery/piechart.html
sample here
http://www.mobilegreatness.com/charts.html
sample here
http://www.mobilegreatness.com/charts.html
Wednesday, March 4, 2009
WAP forms Verizon Open wave devices
I have found one small issue with some veizon phones when it comes to supporting forms in WAP on some verozin phones in the User profile there is a method called "Forms inside of tables" this value is either true or false. If false your forms will NOT be displayed if they are inside of html (tables , tr etc. etc.) it is good proactice for WAP 2.0 to not have forms inside of html tags this will fix your issue.
Tuesday, March 3, 2009
Ad mobs ads iphone sdk
Google Adsense SMS
a.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Keep Text Messaging FREE AND SAFE click our ad below.");
Response.Write("
");
// Response.Write("Visit www.mobilegreatness.com From your PC to get your Free SMS widget");
// Response.Write("To support us, please click on below google ad");
//Response.Write("
");
string googleScheme = "http://";
string googleHost = Server.UrlEncode(googleScheme + Request.ServerVariables["HTTP_HOST"]);
double googleTime = (DateTime.Now - new
DateTime(1970, 1, 1)).TotalSeconds;
double googleDt = (1000 * googleTime) + Math.Round(1000 * Timer() -
(int)Timer());
string https = Request.ServerVariables["HTTPS"];
if (https.IndexOf("on") > -1)
{
googleScheme = "https://";
}
string googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?ad_type=text_image&channel=" +
"&client=ca-mb-pub-3965045331381248" +
"&color_border="+googleColor("555555", googleTime) +
"&color_bg="+ googleColor("EEEEEE", googleTime) +
"&color_link=" + googleColor("400058", googleTime) +
"&color_text=" + googleColor("000000", googleTime) +
"&color_url=" + googleColor("008000", googleTime) +
"&dt=" +googleDt +
"&format=mobile_single" +
"&host="+googleHost +
"&ip=" + Server.UrlEncode(Request.ServerVariables["REMOTE_ADDR"]) +
"&markup=xhtml&oe=utf8&output=xhtml" +
"&ref=" + Server.UrlEncode(Request.ServerVariables["HTTP_REFERER"])
+"&url=" + googleHost +
Server.UrlEncode(Request.ServerVariables["URL"]) +
"&useragent=" +
Server.UrlEncode(Request.ServerVariables["HTTP_USER_AGENT"]) +
googleScreenRes();
WebClient wc = new WebClient();
string googleAdOutput = wc.DownloadString(googleAdUrl);
Response.Write(googleAdOutput);
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create(googleAdUrl);
HttpWebResponse resp = null;
try
{
req.Timeout =
Int32.Parse(ConfigurationManager.AppSettings["Google_Timeout_Msec"]);
resp = (HttpWebResponse)req.GetResponse();
Stream responseStream = resp.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream,
Encoding.UTF8);
googleAdOutput = streamReader.ReadToEnd();
}
catch (HttpException htex)
{
}
catch (Exception exception)
{
googleAdOutput = "";
}
finally
{
// According to MS doc. it's only necessary to close either
if (resp != null) {
resp.Close();
}
}
}
string googleColor(string value, double random)
{
string[] colorArray = value.Split(',');
return colorArray[(int)random % colorArray.Length];
}
string googleScreenRes()
{
string screenRes = Request.ServerVariables["HTTP_UA_PIXELS"];
char delimiter = 'x';
if (screenRes == null)
{
screenRes = Request.ServerVariables["HTTP_X_UP_DEVCAP_SCREENPIXELS"];
delimiter = ',';
}
if (screenRes != null)
{
string[] resArray = screenRes.Split(delimiter);
if (resArray.GetUpperBound(0) + 1 == 2)
{
return "&u_w=" + resArray[0] + "&u_h=" + resArray[1];
}
}
return "";
}
double Timer()
{
return (DateTime.Now - DateTime.Now.Date).TotalSeconds;
}
}
a.aspx
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Web" %>
<% double googleTime = (DateTime.Now - new DateTime(1970,1,1)).TotalSeconds; double googleDt = (1000 * googleTime) + Math.Round(1000 * Timer() -(int)Timer()); string googleScheme = "http://"; string https = Request.ServerVariables["HTTPS"]; if (https.IndexOf("on") > -1)
{
googleScheme = "https://";
}
string googleHost = Server.UrlEncode(googleScheme +Request.ServerVariables["HTTP_HOST"]);
string googleAdOutput = "";
string googleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?" +
"ad_type=text_image" +
"&channel=" +
"&client=ca-mb-pub-3965045331381248" +
"&color_border=" + googleColor("555555", googleTime) +
"&color_bg=" + googleColor("EEEEEE", googleTime) +
"&color_link=" + googleColor("400058", googleTime) +
"&color_text=" + googleColor("000000", googleTime) +
"&color_url=" + googleColor("008000", googleTime) +
"&dt=" + googleDt +
"&format=mobile_single" +
"&host=" + googleHost +
"&ip=" + Server.UrlEncode(Request.ServerVariables["REMOTE_ADDR"]) +
"&markup=xhtml" +
"&oe=utf8" +
"&output=xhtml" +
"&ref=" + Server.UrlEncode(Request.ServerVariables["HTTP_REFERER"]) +
"&url=" + googleHost +
Server.UrlEncode(Request.ServerVariables["URL"]) +
"&useragent=" +
Server.UrlEncode(Request.ServerVariables["HTTP_USER_AGENT"]) +
googleScreenRes();
HttpWebRequest req = (HttpWebRequest)
WebRequest.Create(googleAdUrl);
HttpWebResponse resp;
try {
req.Timeout =
Int32.Parse(ConfigurationManager.AppSettings["Google_Timeout_Msec"]);
resp = (HttpWebResponse)req.GetResponse();
Stream responseStream = resp.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream,Encoding.UTF8);
googleAdOutput = streamReader.ReadToEnd();
resp.Close();
} catch (Exception exception) {
// Something went wrong. This is a good place to log theexception.
googleAdOutput = "";
}
%> -->
AJAX Timer asp.net Datagrid
ajax.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
GridData.DataSource = getData();
GridData.DataBind();
Page.DataBind();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
//Label1.Text = "Total Messages of " + DateTime.Now.ToLongTimeString();
}
public static DataTable getData()
{
DataSet ds = new DataSet();
try
{
OdbcConnection conn = new OdbcConnection(ConfigurationManager.ConnectionStrings["connection_string"].ConnectionString);
string query = String.Format("Stored Procedure");
OdbcDataAdapter adap = new OdbcDataAdapter(query, conn);
adap.Fill(ds);
}
catch (Exception ex)
{
}
return ds.Tables[0];
}
}
ajax.aspx
protected void Page_Load(object sender, EventArgs e)
{
GridData.DataSource = getData();
GridData.DataBind();
Page.DataBind();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
//Label1.Text = "Total Messages of " + DateTime.Now.ToLongTimeString();
}
public static DataTable getData()
{
DataSet ds = new DataSet();
try
{
OdbcConnection conn = new OdbcConnection(ConfigurationManager.ConnectionStrings["connection_string"].ConnectionString);
string query = String.Format("Stored Procedure");
OdbcDataAdapter adap = new OdbcDataAdapter(query, conn);
adap.Fill(ds);
}
catch (Exception ex)
{
}
return ds.Tables[0];
}
}
ajax.aspx
Delete ALL mail out of queue SENDMAIL
run this as a cron
0,15,30,45 * * * * find /var/spool/mqueue -type f -print0 | xargs -0 rm -rf
as you can see it will do it every 15 minutes works perfect fedora sendmail
0,15,30,45 * * * * find /var/spool/mqueue -type f -print0 | xargs -0 rm -rf
as you can see it will do it every 15 minutes works perfect fedora sendmail
CURL post from asp.net to php
curlpost.aspx.cs
public string HttpPost(string uri, string parameters)
{
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
Stream os = null;
try
{
webRequest.ContentLength = bytes.Length;
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
}
catch (WebException ex)
{
}
finally
{
if (os != null)
os.Close();
}
try
{
WebResponse webResponse = webRequest.GetResponse();
if (webResponse == null)
{ return null; }
StreamReader sr = new StreamReader(webResponse.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (WebException ex)
{
}
return null;
}
objmm.HttpPost("http://phppaghere", "from_number=" + dtVot.Rows[0]["fromphonenumber"].ToString() + "&to_number=" + phonenumber);
public string HttpPost(string uri, string parameters)
{
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
Stream os = null;
try
{
webRequest.ContentLength = bytes.Length;
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
}
catch (WebException ex)
{
}
finally
{
if (os != null)
os.Close();
}
try
{
WebResponse webResponse = webRequest.GetResponse();
if (webResponse == null)
{ return null; }
StreamReader sr = new StreamReader(webResponse.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (WebException ex)
{
}
return null;
}
objmm.HttpPost("http://phppaghere", "from_number=" + dtVot.Rows[0]["fromphonenumber"].ToString() + "&to_number=" + phonenumber);
Consuming SOAP service (asmx) in php
$this->key,
'phonenumber' => $member_phone_number,
'memberid' => $member_id,
'programid' => $program_id,
'shortcode' => "something_here"
);
try {
logger('info', "Error Message");
$client = new SoapClient($this->WSDL);
$client->SOAPMETHODHERE($params);
} catch (SoapFault $exception) {
mailer('err', "EXCEPTION IN Calling : " . $exception);
}
$this->sendMessage($member_id, $this->confirmMsgID);
}
}
//ELSE NUM_ROWS <= 0 //DONT DO ANYTHING, THIS PHONE IS NEVER SEEN BEFORE //SOMEONE JUST SENDING OUT OF THE BLUE logger('info', " DOING NOTHING"); } private function sendMessage($member_id, $message_id){ logger('info', "SEND MESSAGE function::Sending msg ID=" . $message_id . " To memmberid=" . $member_id); class_exists('Outgoing_Message_Queue') || require('classes/outgoing_message_queue.php'); $outgoing_message_obj = new Outgoing_Message_Queue($message_id); $outgoing_message_obj->sendToMember($member_id);
}
}
?>
$this->key,
'phonenumber' => $member_phone_number,
'memberid' => $member_id,
'programid' => $program_id,
'shortcode' => "something_here"
);
try {
logger('info', "Error Message");
$client = new SoapClient($this->WSDL);
$client->SOAPMETHODHERE($params);
} catch (SoapFault $exception) {
mailer('err', "EXCEPTION IN Calling : " . $exception);
}
$this->sendMessage($member_id, $this->confirmMsgID);
}
}
//ELSE NUM_ROWS <= 0 //DONT DO ANYTHING, THIS PHONE IS NEVER SEEN BEFORE //SOMEONE JUST SENDING OUT OF THE BLUE logger('info', " DOING NOTHING"); } private function sendMessage($member_id, $message_id){ logger('info', "SEND MESSAGE function::Sending msg ID=" . $message_id . " To memmberid=" . $member_id); class_exists('Outgoing_Message_Queue') || require('classes/outgoing_message_queue.php'); $outgoing_message_obj = new Outgoing_Message_Queue($message_id); $outgoing_message_obj->sendToMember($member_id);
}
}
?>

Consuming a web SOAP web service (asmx) with iphone (sdk)
here i go
View controller
//
// Hello_SOAPAppDelegate.m
// Hello_SOAP
//
// Created by Dave McAnall on 11/2/08.
// Copyright __MyCompanyName__ 2008. All rights reserved.
//
#import "Hello_SOAPViewController.h"
@implementation Hello_SOAPViewController
@synthesize greeting, tonumber,fromnumber,nameInput, webData, soapResults, xmlParser;
-(IBAction)buttonClick:(id)sender
{
recordResults = FALSE;
NSString *soapMessage = [NSString stringWithFormat:
@"\n"
"
"
"
"
"
"
"
"
"
"
];
NSLog(soapMessage);
NSURL *url = [NSURL URLWithString:@"http://yourasmx.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/SendTextToFriend" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
[nameInput resignFirstResponder];
[fromnumber resignFirstResponder];
[tonumber resignFirstResponder];
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"ERROR with theConenction");
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(theXML);
[theXML release];
if( xmlParser )
{
[xmlParser release];
}
xmlParser = [[NSXMLParser alloc] initWithData: webData];
[xmlParser setDelegate: self];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
[connection release];
[webData release];
}
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
attributes: (NSDictionary *)attributeDict
{
if( [elementName isEqualToString:@"SendTextToFriendResult"])
{
if(!soapResults)
{
soapResults = [[NSMutableString alloc] init];
}
recordResults = TRUE;
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if( recordResults )
{
[soapResults appendString: string];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if( [elementName isEqualToString:@"SendTextToFriendResult"])
{
recordResults = FALSE;
greeting.text = soapResults;
[soapResults release];
soapResults = nil;
}
}
/*
Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
}
*/
/*
Implement viewDidLoad if you need to do additional setup after loading the view.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc
{
[xmlParser release];
[super dealloc];
}
@end
Header
//
// Hello_SOAPViewController.h
// Hello_SOAP
//
// Created by Dave McAnall on 11/2/08.
// Copyright __MyCompanyName__ 2008. All rights reserved.
//
#import
@interface Hello_SOAPViewController : UIViewController
{
IBOutlet UITextField *nameInput;
IBOutlet UITextField *tonumber;
IBOutlet UITextField *fromnumber;
IBOutlet UILabel *greeting;
NSMutableData *webData;
NSMutableString *soapResults;
NSXMLParser *xmlParser;
BOOL *recordResults;
}
@property(nonatomic, retain) IBOutlet UITextField *nameInput;
@property(nonatomic, retain) IBOutlet UITextField *tonumber;
@property(nonatomic, retain) IBOutlet UITextField *fromnumber;
@property(nonatomic, retain) IBOutlet UILabel *greeting;
@property(nonatomic, retain) NSMutableData *webData;
@property(nonatomic, retain) NSMutableString *soapResults;
@property(nonatomic, retain) NSXMLParser *xmlParser;
-(IBAction)buttonClick: (id) sender;
@end
XIB
Subscribe to:
Posts (Atom)
