PDA

View Full Version : Email contents of UIWebView and post to Facebook




newtoiphonesdk
Jul 30, 2010, 01:56 PM
I am working on an app that has a WebView of a wordpress blog that I set up. I have seen other blog apps that you can click to either send an email that has the entire contents of the article, or post it to Facebook. How is this done?



newtoiphonesdk
Jul 30, 2010, 08:49 PM
Even just email would be good if not facebook

seepel
Jul 31, 2010, 05:29 AM
I'm not familiar with JavaScript, but it seems like this is a candidate for the stringByEvaluatingJavascript: method sf UiWebview.

dejo
Jul 31, 2010, 09:29 AM
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A306 Safari/6531.22.7)

For email, there's the MessageUI framework. For Facebook, there's Facebook Connect. For something that handles these and more (incl. Twitter), consider something like ShareKit.

newtoiphonesdk
Jul 31, 2010, 09:56 AM
How would I code either of those choices to do it?

dejo
Jul 31, 2010, 04:22 PM
How would I code either of those choices to do it?
I'm not sure exactly what answer you are looking for. I would start by looking at the documentation for those things, understanding how they are used in sample code, maybe going through some tutorials, etc. If that's not what you want, please explain specifically what kind of answer you seek.

newtoiphonesdk
Jul 31, 2010, 05:14 PM
I thought I was specific. I have an app with a webview that pulls in a blog. I want to make a button to email the contents of the blog article in the window and also be able to post to fb

dejo
Aug 1, 2010, 12:58 AM
Wirelessly posted (Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16)

No, you're being specific in what you are trying to achieve. Now you need to be specific in what help from us you are trying to solicit.

newtoiphonesdk
Aug 1, 2010, 01:07 AM
Ok , specifically I want you to tell me the code that will pull the article from the webview and put it in the body of an email when the button is pressed

robbieduncan
Aug 1, 2010, 06:01 AM
Ok , specifically I want you to tell me the code that will pull the article from the webview and put it in the body of an email when the button is pressed

You want us to write your app for you? For free? Get real.

dejo
Aug 1, 2010, 11:04 AM
You want us to write your app for you? For free? Get real.
I was going to ask them where we should send the bill, but this'll do. Thanks, robbie. :)

robbieduncan
Aug 1, 2010, 11:27 AM
I was going to ask them where we should send the bill, but this'll do. Thanks, robbie. :)

We can't offer to do the work for money (http://forums.macrumors.com/showthread.php?t=604011) ;)

newtoiphonesdk
Aug 1, 2010, 12:15 PM
I don't want the app built for me. I need one part help on learning how to make the button that will email contents of the article. I only mentioned in jest you code it for ne comment because the one post said I wasn't being very specific and I knew of no other way to be more specific beyond the original post.

robbieduncan
Aug 1, 2010, 12:17 PM
And he told you exactly which part of the documentation you need to read. That is all a programmer needs. The next step is writing the code. There is nothing in between.

newtoiphonesdk
Aug 1, 2010, 12:46 PM
I have never programmed before and apples documentation is confusing and doesn't offer any sample code for doing what I'm trying. Is it too much to ask for a small sample code for pulling contents of view to am email body?

chown33
Aug 1, 2010, 01:02 PM
I have never programmed before and apples documentation is confusing and doesn't offer any sample code for doing what I'm trying. Is it too much to ask for a small sample code for pulling contents of view to am email body?
Why do you think such "sample code" would be small? Just because it can be summarized in 50 words or less doesn't necessarily mean it can be coded in 50 words, or 50 lines, or even 50 pages.

So yes, it is too much to ask.

If you don't know how to solve it yourself, then break it down into sub-problems you can solve by yourself. Or study the necessary features and functions until you can solve it yourself. You'd better get used to this process, because it's what all programming really is: figuring out how to do something you didn't know before, then doing it.

Example of Breaking It Down (a principle called decomposition):
pull the article from the webview and put it in the body of an email when the button is pressed


1. Pull the article from the webview.
2. Put it in the body of an email.
3. When a button is pressed.

Decomposing 3:
3a. Define a button in IB.
3b. Define an action method.
3c. Connect the button to the action method.

Decomposing 1:
1a. Decide on a representation for the article. NSString or NSAttributedString or something else. It depends on what you're trying to send in the email.
1b. Find a method of the view that returns a type close to what you want, or exactly what you want.
1c. Perform any conversion on the data, such as line-wrapping or whatever, that might be needed for sending as an email.

Decomposing 2:
2a. Investigate email API: classes, methods, etc.
2b. See how API affects represention from 1a.
2c. Decompose into further sub-parts: addressing email, setting subject, setting body, sending, etc.


If you find Apple's docs confusing, then it suggests you're in over your head, and should go back and review whatever is confusing you. Again, get used to this process, because it will happen continuously.