Closed DanMossa closed 9 years ago
This could be a header issue. Try this branch: #64
So I fixed that up and i tried sending a snapchat. It logged me out of snapchat which I'm assuming is correct, but then when I logged back in I don't see anything sent. I also tried it with uploading a story and I don't see anything I've uploaded.
@Dgameman1 How did you fix? I am still getting issues with updated headers.
@Spurlex I actually did not get it to work yet. Nothing is being sent at the moment =/
@Dgameman1 Could you show me a sample of your code please, Also @Spurlex could you describe to me the issues you are having?
I'm guessing you're using the API on the server, Does your code work locally?
@hako Neither one of these seem to be doing anything other than logging me out <?php
require_once('src/snapchat.php');
// Log in:
$snapchat = new Snapchat('XXX', 'XXX');
// Upload a snap and send it to me for 8 seconds:
//$id = $snapchat->upload(
// Snapchat::MEDIA_IMAGE,
// file_get_contents('/images/arielol.jpg')
//);
//$snapchat->send($id, array('allenbgd'), 4);
$id = $snapchat->upload(
Snapchat::MEDIA_VIDEO,
file_get_contents('/images/arielol.jpg')
);
// Log out:
$snapchat->logout();
?>
@Dgameman1
require_once('src/snapchat.php');
// Log in: $snapchat = new Snapchat('XXX', 'XXX');
// Upload a snap and send it to me for 8 seconds: $id = $snapchat->upload( Snapchat::MEDIA_IMAGE, file_get_contents('/images/arielol.jpg') ); $snapchat->send($id, array('allenbgd'), 4);
$id = $snapchat->upload( Snapchat::MEDIA_VIDEO, file_get_contents('/images/arielol.jpg') );
// Log out: $snapchat->logout();
?>
@Snowlav I just commented the send private snapchat just to show that I'm trying to only use one. That doesn't seem to work either lol
"Neither one of these seem to be doing anything other than logging me out" You put "//" in front of the entire area, I figured that was the problem haha, my bad.
@Snowlav Lol i wish it was that easy :(
Uh any ideas guys ?:O
Uh any ideas guys ?:O
I'm having a similar issue. Without digging a little deeper, I can't guarantee this, but my snaps won't upload... However, if they do upload, they send perfectly. When I dug more deeply, my POST function inside snapchat_agent would be returning false due to the CURL headers coming back as 401 Unauthorized.
@KyleBoyer How would you know that they send perfectly if they don't upload?
The upload endpoint responds differently with the change of client version. I've just documented the latest version of the /ph/upload :
Used to upload media to the server
{}
No content.
So what do you suggest I do? Just wait till it gets fixed? @cuonic
You could try participating in the development of a solution, I've gave you the request and response parameters of the new upload system, you just need to change a few things in the PHP class.
On 02/01/2015 08:25, Dgameman1 wrote:
So what do you suggest I do? Just wait till it gets fixed? @cuonic https://github.com/cuonic
— Reply to this email directly or view it on GitHub https://github.com/JorgenPhi/php-snapchat/issues/63#issuecomment-68511930.
You could try participating in the development of a solution, I've gave you the request and response parameters of the new upload system, you just need to change a few things in the PHP class.
I just adjusted my code and tried those parameters with that endpoint, and I still get back a 401 Unauthorized response. The only thing that I could've screwed up with, was the features_map... I tried leaving that null.
Got it working with a few modifications, here is my testing code : http://files.lab.cuonic.com/NWI2MzJ
@cuonic Page not found :O
@Dgameman1 Page not found for the download, when uploading a snap, when sending the snap ?
@cuonic http://files.lab.cuonic.com/NWI2MzJ says 404 Not Found
@Dgameman1 Sorry about that, seems to work for other people though. Try this : http://dev.cuonic.com/SnapUpload.zip
Hmm that's really strange. Still 404 http://i.imgur.com/jkBRQAn.png Let me try going through proxy
And it worked ... @cuonic Very weird. Thank you though! Let me try this out!
@Dgameman1 Check your DNS servers they don't see very... up to date :) In upload.php you just need to add your Snapchat username and password for it to work.
@cuonic http://i.imgur.com/txR6m7H.png :( I promise I'm not retarded
I've got exactly the same code and it's working good. If you're getting "Error encountered" then it's good news, it means that the upload was successful, so it's just the "sending" of the snap that screws up.
Use the following code to debug the sending :
<?php
if($_POST) {
require_once("snapchat.php");
$snapchat = new Snapchat();
$login = $snapchat->login('USERNAME', 'PASSWORD');
if(filesize($_FILES['image']['tmp_name']) > 1000000) {
$message = "File too big.";
} else {
$upload = $snapchat->upload(Snapchat::MEDIA_IMAGE, file_get_contents($_FILES['image']['tmp_name']));
if($upload['error'] == 1) {
$message = $upload['message'];
} else {
$return = $snapchat->send($upload['media_id'], array($_POST['username']), $_POST['seconds']);
echo "<pre>";
var_dump($return);
echo "</pre>";
if($return['error'] == 0) {
$message = "Snap sent.";
} else {
$message = "Error encountered.";
}
}
}
}
?>
And paste here what you get back in the
tags
Um, now when I Just go to the page, i get this error http://i.imgur.com/HTMmo9n.png @cuonic
Well that's good because now we know the problem. Either the file you are trying to send is not valid "media", try starting off by sending a small JPEG image, don't try videos / large images just yet. If not the the media type is invalid, try replacing Snapchat::MEDIA_IMAGE
with 0
in upload.php
@cuonic I didn't actually fill out the form or anything. I just went to the page and it gave me that error =O
Like I didn't send an image yet
Oh ok it's detecting a POST request by fetching the page... Oh dear. Replace Line 3 if($_POST)
with if(isset($_POST['username']))
and don't refresh the page after posting, just call it from the address bar.
I changed the code and the same thing happens when i go to the page without posting lol http://i.imgur.com/fG5VcD4.png What if I make an ajax request and put the PHP into a different page? @cuoinic
Damn, Ajax won't work for the file upload. How about changing line 3 to if($_SERVER['REQUEST_METHOD'] == "POST")
@cuonic same error =/ Is it working with you? And you're right about it posting just by refreshing. Because I get logged out just by refreshing =o
The original code works for me as well as all the modifications.
What browser are you using ? What web server ?
@cuonic I'm using google chrome and it's currently hosted up online
Try running it locally with a WAMP / LAMP server
Okay cool! So, this time nothing happened and the page loaded fine. I fill everything out and I get this http://i.imgur.com/kleluAa.png but I didn't log out of snapchat nor did it send anything
This is not working very well at all for you. Are you sure you are using the provided snapchat.php and snapchat_agent.php ? Try using the following file as snapchat.php
: https://gist.github.com/cuonic/bb106e1ce978ebf71c6e
@cuonic This does not make any sense. I legit used the file you sent me to download but apparently the snapchat.php you just sent me to use on github is different. so I used that and now the error i get is this..
Good, well something is screwing up with the login. Use the following as snapchat_agent.php
: https://gist.github.com/cuonic/449a34af812fefc72522
Still get the same No Authentication Details =/
Just want to say thank you so much btw
But the thing is, it still logs me out :o
Ok try adding the following :
echo "<pre>";
var_dump($login);
echo "</pre>";
just after $login = $snapchat->login("username", "password");
And paste the output here
There's the problem :) Try doing a Google search for that one
@cuonic So I'm assuming the script doesn't see ca_bundle.crt
curl_setopt($ch, CURLOPT_CAINFO, 'ca_bundle.crt');
but ca_bundle.crt is with every other file?
@Dgameman1 : Curl requires an absolute path for the certificate file apparently, so you need to change line 318 of snapchat_agent.php
with the full path : curl_setopt($ch, CURLOPT_CAINFO, '/full/path/to/file/ca_bundle.crt');
For whatever reason, nothing is being sent. And when I tried using the test I get an error saying "Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /snap/tests/phpSnapchatTest.php on line 3"