View previous topic :: View next topic |
Author |
Message |
trevi
Joined: 13 Nov 2003 Posts: 10
|
Posted: Thu Nov 13, 2003 2:20 am Post subject: Trying to use it with Pivot |
|
|
I'm trying to use MMS Diary with pivot.
So I first made a script that would mail the pic to an adres.
Source code of the script
THen I tried to combine it with Pivot:
Source code of the script
But it doesn't work with Pivot.
Why I don't know.
When I use pivot alone without the mail function it works bu I get an message error but pivot saves the image.
When I use the mail function I get an empty email.
What am I doing wrong? What are the variables?
because the last solution I have the mmsdiary with mail function.
And I then want to connect via a fsocketopen to the script that works with pivot but without the mailfunction. But what are the variables? I don't know what to pass on. Can you help me with it?
Thx |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Thu Nov 13, 2003 6:57 pm Post subject: |
|
|
I honestly don't have any idea what Pivot is so I cannot help you with any details. Something that might help you is a script that you can post with from your PC instead of your phone. If you use that script you will see any error messages sent from the server - if any.
The following script does what you need:
Code: |
#!/usr/bin/php -q
<?
$argv = $_SERVER["argv"];
$host = $argv[1];
$path = $argv[2];
$filename = $argv[3];
$length = filesize( $filename );
$filep = fopen( $filename, "rb" );
$message = fread( $filep, $length );
$fp = fsockopen( $host, 80, $errno, $errstr, 30 );
fwrite( $fp,
"POST " . $path . " HTTP/1.0\x0D\x0A" .
"Host: " . $host . "\x0D\x0A" .
"User-Agent: MMS Poster\x0D\x0A" .
"Content-Length: " . $length . "\x0D\x0A" .
"Content-Type: application/vnd.wap.mms-message\x0D\x0A" .
"\x0D\x0A".
$message );
while (!feof($fp))
{
echo fgets ($fp,128);
}
echo "\n";
?>
|
You might need to change the first line in the script depending on your system though. Use it as follows:
./poster.php <host> <path> <file>
example:
./poster.php hellkvist.org /testd/send.php mmssample.bin
To get a sample to post all you need to do is to store the HTTP_RAW_POST_DATA variable to a file.
Cheers,
Stefan |
|
Back to top |
|
|
trevi
Joined: 13 Nov 2003 Posts: 10
|
Posted: Sat Nov 15, 2003 4:15 am Post subject: |
|
|
Hey Stefan,
I don't think you understand me.
I just want to do the following:
I have your send.php, I built and extra function in it, a mail function,
which formats a mail and sends that.
Now I want to send the variables that send.php gets to an other script on an other server. I would like to do that with a fsockopen, but I don't know the variables. So I have to know what the variables are I have to use for the fsockopen.
So i can make something like:
pivot_send.php?subject=blaat&message=test&picture=blaat.jpg
I hope you understand.
PS
this is the code I try to use to redirect/reuse the variables for the next script:
<?
$fp = fsockopen ("www.arvidbux.nl", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "POST /log/pivot/send.php?$HTTP_RAW_POST_DATA HTTP/1.0\r\nHost: www.arvidbux.nl\r\n\r\n");
while (!feof($fp)) {
$test = fgets ($fp,128);
}
fclose ($fp);
}
?>
so actually the mms that is send will be processed by 2 individual scripts |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Sat Nov 15, 2003 10:33 am Post subject: |
|
|
I see. Well, problem is that the contents of the HTTP_RAW_POST_DATA is the binary MMS and not something that Pivot would understand so your script will not work unfortunately. And also, in a post you don't supply the data in the query-string as you do (after the ? in the URL). You send the data in the message instead.
So does Pivot want a GET or a POST? Determine that first.
Then determine what variables you will need to be able to send a message to Pivot - what is its interface?
If Pivot has a pivot_send.php that you access like you do (or is that something you write yourself?) it appears to be GET method. The subject and text message you can easily transfer like that from MMS Diary in the GET request. The image though is the problem. If you do it like that and transwer a filename, then that file will not exist on the other server of course - it will only be on the MMS Diary side where it has been extracted. You can transfer binary data in the GET request but do consider doing a post instead.
What I would do, instead of this two phase method, is to instead put MMS Diary on the Pivot machine, figure out how Pivot stores messages (is it a MYSQL database?) in the database and just do the same from the MMS Diary script. |
|
Back to top |
|
|
trevi
Joined: 13 Nov 2003 Posts: 10
|
Posted: Sat Nov 15, 2003 12:07 pm Post subject: |
|
|
Hi Stefan,
well the send.php of pivot is just a modified send.php and it works you can also directly post the MMS to that script but I will get a timeout error.
But it saves the image.
Pivot works with a text database.
So I want to use the pivot script and the mmsdiary script with the mail function.
I can't use them 1 one script because the script will cause a timeout error.
So when I can redirect the variables that were sent to send.php to pivot_send.php both scripts will work!! |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Sat Nov 15, 2003 11:15 pm Post subject: |
|
|
I see, now I understand. I didn't know it was MMS Diary on the other side as well.
Well, so all you need to do then is to repost the HTTP_RAW_POST_DATA. See the script in this thread on how to post a MMS. Just replace the message part with HTTP_RAW_POST_DATA and it will work. There are no variables involved in send.php. There is just the content-type which is application/vnd.wap.mms-message and then it's the binary MMS (which in PHP gets stored in the HTTP_RAW_POST_DATA. So look at the script on how it posts a message. But perhaps that is what you are doing already?
If you are already doing that and the Pivot side works halfway I think it's a problem with your PHP or settings on that side. Then try my script (as I said) and post a message directly towards that script and see if you get any error messages. The usual problems people have when they get only the image unpacked and nothing else, is that they don't have the gd-module (check with php -m). That module is used to create thumbnails of big images for instance. If you don't have gd module on the Pivot side you will need to install it or edit the hooks.php file so that you remove all image hooks - then it won't use gd (but not thumbnails will be created either).
But I'm not sure if it will work anyway. If you get a timeout error if you put both in at once I think you will still get it in this scenario. You don't save any time by doing this. The phone will still wait for a reply which you will only send once you have transmitted it to the other server so the same actions will be performed before the phone gets a reply. So the best bet there is to do the relaying in a subprocess.
But there could be other reasons for a timeout in the phone. That's why I keep nagging you about posting with the script instead so you'll see the proper error messages. The phones will give out the weirdest messages sometimes. A timeout could come from the server just dying before sending out the reply (which might be caused by an error in the output).
Good luck! |
|
Back to top |
|
|
trevi
Joined: 13 Nov 2003 Posts: 10
|
Posted: Wed Nov 19, 2003 10:08 am Post subject: |
|
|
Hi Stefan,
you told me jsut to repost the raw data.
But how do I do that?
Could you give me an example?
thx in advance! |
|
Back to top |
|
|
trevi
Joined: 13 Nov 2003 Posts: 10
|
Posted: Wed Nov 19, 2003 2:34 pm Post subject: |
|
|
And the servers are the same.
Same config same php and MMS diary works fine on them both! |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Thu Nov 20, 2003 8:29 am Post subject: |
|
|
An example on how to repost the raw data? But I just sent you that in the poster script. But anyway. I'll show you again more clearly:
Code: |
$host = "second.server.ip.address"; // Put IP of your second server here
$path = "/diary/send.php";
$message = $HTTP_RAW_POST_DATA;
$length = strlen( $message );
$fp = fsockopen( $host, 80, $errno, $errstr, 30 );
fwrite( $fp,
"POST " . $path . " HTTP/1.0\x0D\x0A" .
"Host: " . $host . "\x0D\x0A" .
"User-Agent: MMS Poster\x0D\x0A" .
"Content-Length: " . $length . "\x0D\x0A" .
"Content-Type: application/vnd.wap.mms-message\x0D\x0A" .
"\x0D\x0A".
$message );
while (!feof($fp))
{
echo fgets ($fp,128);
}
|
Good luck! |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Thu Nov 20, 2003 8:32 am Post subject: |
|
|
...oh sorry...remove the while loop at the end as it does a print of the returned message. That is not good as it will screw up the return message to the phone. It was a left over of the old script |
|
Back to top |
|
|
trevi
Joined: 13 Nov 2003 Posts: 10
|
Posted: Thu Nov 20, 2003 1:59 pm Post subject: |
|
|
Hi Stefan,
thx for your replies!
It works!
Thank YOU!!! |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Thu Nov 20, 2003 6:53 pm Post subject: |
|
|
Cool! |
|
Back to top |
|
|
SanderB
Joined: 05 Oct 2003 Posts: 4
|
Posted: Mon Nov 24, 2003 12:46 pm Post subject: |
|
|
OK.. can we try 'n recap?
Trevi: You are sending your MMS:es to a custom script, which forwards em to an email script AND the MMsDiary script?
If so: pass da dutch. I know some guy who would love to get his hands on that! |
|
Back to top |
|
|
Peffis Site Admin
Joined: 09 Sep 2003 Posts: 324 Location: Sweden
|
Posted: Mon Nov 24, 2003 6:11 pm Post subject: |
|
|
What Trevi is doing I think is, if I understand it correctly, that he sends MMS:es to a customized MMS Diary installation which sends it out as an email BUT ALSO forwards it to another MMS Diary installation which is the MMS Diary/Pivot join. So two MMS Diary hacks - one with email and forwarding added and one with Pivot added.
Or perhaps I was drunk when I understood it
...or sober when I misunderstood it...
...or something... |
|
Back to top |
|
|
Arnix
Joined: 17 Sep 2003 Posts: 11
|
|
Back to top |
|
|
|