Using Curl with PFA

55 views
Skip to first unread message

Juerujin

unread,
Nov 6, 2010, 7:43:21 PM11/6/10
to PhpForAndroid
Is there any possibility of using Curl with PFA?
Message has been deleted

Norman E. Avila G.

unread,
Nov 7, 2010, 10:28:48 AM11/7/10
to php-for...@googlegroups.com

Yes. Algo if you want just to call a restful app from phpFA with file_get_contents

On Nov 7, 2010 12:12 AM, "Hypnotic Guy" <the...@gmail.com> wrote:

jkar...@gmail.com

unread,
Nov 7, 2010, 12:38:37 PM11/7/10
to php-for...@googlegroups.com

I'm actually trying to have a PHP script send data to another one. Can I use your method for that ?

> --
> You received this message because you are subscribed to the Google Groups "PhpForAndroid" group.
> To post to this group, send email to php-for...@googlegroups.com.
> To unsubscribe from this group, send email to php-for-andro...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/php-for-android?hl=en.
>

Norman E. Avila G.

unread,
Nov 7, 2010, 12:48:51 PM11/7/10
to php-for...@googlegroups.com

That is what I do. A tracker app that sends GPS position to my DB via HTTP get

On Nov 7, 2010 9:38 AM, "jkar...@gmail.com" <jkar...@gmail.com> wrote:
> I'm actually trying to have a PHP script send data to another one. Can I use
> your method for that ?
> On Nov 7, 2010 10:28 AM, "Norman E. Avila G." <neav...@gmail.com> wrote:
>> Yes. Algo if you want just to call a restful app from phpFA with
>> file_get_contents
>> On Nov 7, 2010 12:12 AM, "Hypnotic Guy" <the...@gmail.com> wrote:
>>
>> --
>> You received this message because you are subscribed to the Google Groups
> "PhpForAndroid" group.
>> To post to this group, send email to php-for...@googlegroups.com.
>> To unsubscribe from this group, send email to

jkar...@gmail.com

unread,
Nov 7, 2010, 1:47:47 PM11/7/10
to php-for...@googlegroups.com

Cool I'm trying to send email data to a remote PHP file which then sends it. Would you mind giving me an example of how you did yours?

On Nov 7, 2010 12:48 PM, "Norman E. Avila G." <neav...@gmail.com> wrote:
> That is what I do. A tracker app that sends GPS position to my DB via HTTP
> get
> On Nov 7, 2010 9:38 AM, "jkar...@gmail.com" <jkar...@gmail.com> wrote:
>> I'm actually trying to have a PHP script send data to another one. Can I
> use
>> your method for that ?
>> On Nov 7, 2010 10:28 AM, "Norman E. Avila G." <neav...@gmail.com> wrote:
>>> Yes. Algo if you want just to call a restful app from phpFA with
>>> file_get_contents
>>> On Nov 7, 2010 12:12 AM, "Hypnotic Guy" <the...@gmail.com> wrote:
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>> "PhpForAndroid" group.
>>> To post to this group, send email to php-for...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>> php-for-andro...@googlegroups.com<php-for-android%2Bunsu...@googlegroups.com>

Norman E. Avila G.

unread,
Nov 7, 2010, 1:51:41 PM11/7/10
to php-for...@googlegroups.com
your php on your server (not on the phone,) should have a way to receive what you want  via $_GET and you just call ..  the php in the phone just have to do that.. 

$fileresponse = file_get_contents("http://myremoteserver.com/myfile.php?myparam=". $paramvalue."&anotherparam=".$otherparam);

and that will make to call to that file.. in the server.. you do your own there in myfile.php out of the phone..


Norman E. Avila G.
-------------------------------
USA +1 412 ClimaYa 

jkar...@gmail.com

unread,
Nov 7, 2010, 3:55:48 PM11/7/10
to php-for...@googlegroups.com

That's briliant!! I can't believe I didn't see that option. Thanks again .... I'll give it a shot

Djeezus

unread,
Jun 13, 2011, 4:58:02 PM6/13/11
to php-for...@googlegroups.com
Hi,

I'm actually using the file_get_contents(url) method, but dialogSetItems doesn't show any array elements. 

<?php
require_once("Android.php");
$droid = new Android();

  // get array
  $gem = (array) json_decode(file_get_contents('http://some_uri/json_encoded_array'));
  print_r($gem); // prints out : Array ( [0] => "BLAH" ... )
  $tr = array("Test","Bleh","Blub") ;
  print_r($tr); // prints out : Array ( [0] => "Test" .... )

        // interface start
        $droid->dialogCreateAlert("Take your pick ...");
        $droid->dialogSetItems($gem);
        $droid->dialogShow();
?>

If I use the "$tr" array the elements do show up ... 

is this a bug ?

grtz,
gert

Djeezus

unread,
Jun 17, 2011, 3:55:21 PM6/17/11
to PhpForAndroid
'lo all,

no bug, bad coding from my part :-s

grtz,
gert

Gonzalo García

unread,
Jun 15, 2011, 8:46:36 AM6/15/11
to php-for...@googlegroups.com

You could do an array_values to resolve the issues, in other cases I would advise to use var_dump to see if the element returned is acctually an array and not anything else.

Greetings!
Gonzalo.

> --
> You received this message because you are subscribed to the Google Groups "PhpForAndroid" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/php-for-android/-/9LyhF_UVszcJ.

خالد الناطور

unread,
Jun 17, 2011, 6:51:23 PM6/17/11
to php-for...@googlegroups.com
how i can use it in eclipse ????

2011/6/15 Gonzalo García <gonzalo....@gmail.com>



--
Khalid Al-natour
Web Development at National Net Ventures (N2V.com)
 +962 78 5 800 659
 +962 7 99 33 48 65 


skype : khalid-natour

"إذا لم تكن لديك خطة ستكون جزء من خطة الآخرين"

KouiK

unread,
Aug 9, 2011, 12:44:06 PM8/9/11
to php-for...@googlegroups.com
hi !

Is it possible to use curl function to upload an image to a remote webserver ?

I'm actually using this to send datas to my remote webserver, but is there a way to send a photo from my phone to my serv ?

<?php
require_once ("Variables.php");
require_once ("Android.php");
$droid = new Android();
 

function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers!== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}

// Envoi des données
do_post_request('http://www.mysite.com/test_sendDatas.php','nick='.$nick);
?>

I was looking at this http://dtbaker.com.au/random-bits/uploading-a-file-using-curl-in-php.html but
the curl_init() return a fatal error: undefined function.

Any idea on how to upload a photo ? Thanks
Reply all
Reply to author
Forward
0 new messages