1

Hopefully, someone can spot the error, what I need to do is to first fetch the webpage for a token, then curl the new url with the token attached;

here is my code

$text = $siteName;

  if (preg_match('/;t=([a-zA-Z0-9_-]{43})%3D/',$text,$matches)) {
// Match... vjVQa1PpcFMYuRsz10_H-1z41mWWe8d6ENEnBLE7gug
  echo 'TOKEN: '.$matches[1];

$curltube = curl_init ();
curl_setopt ($curltube, CURLOPT_URL, "http://www.veoh.com/watch?v=opQ9GzRe5qs".$matches[1]);
curl_setopt ($curltube, CURLOPT_RETURNTRANSFER, 0 );
curl_setopt ($curltube, CURLOPT_COOKIEFILE, "cookie8.txt"); 
$curltubeplay = curl_exec ($curltube);
curl_close ($curltube);

echo $curltubeplay;
} else {
// No match
}

and the previous code before that fetches the web-page

curl_setopt ($ch, CURLOPT_URL, "http://www.veoh.com/watch?v=opQ9GzRe5qs");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0 );
curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie8.txt"); 

so hopefully, someone can shed some light

3
  • 3
    When you say spot the error, it'd be helpful if you told is what was going wrong... Commented Apr 8, 2012 at 19:16
  • is your code finding the token? what is the token? what are you expecting the URL to be after you append the token? what is the URL you end up with? Commented Apr 8, 2012 at 19:28
  • oh sorry, I mean what I want to do is have this url veoh.com/watch?v=opQ9GzRe5qs&t= "$matches", so basically extract &t= and insert it into the new url Commented Apr 8, 2012 at 23:29

1 Answer 1

1

My guess (please expand the question to be clear) is that you expect to build a URL like this:

http://www.veoh.com/watch?v=opQ9GzRe5qs;t=abc

But you are building one like this:

http://www.veoh.com/watch?v=opQ9GzRe5qsabc

There are two simple fixes. This one takes the whole matched string, not just the token:

curl_setopt ($curltube, CURLOPT_URL, "http://www.veoh.com/watch?v=opQ9GzRe5qs".$matches[0])

And this one adds back in the missing parts to the URL:

curl_setopt ($curltube, CURLOPT_URL, "http://www.veoh.com/watch?v=opQ9GzRe5qs;t=".$matches[1])
Sign up to request clarification or add additional context in comments.

1 Comment

got it, i had to add another . after the $ so it looks like this "veoh.com/watch?v=opQ9GzRe5qs;t=".$matches[1].)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.