0

I have a php curl script

$ch = curl_init();
$fp = fopen("cache/temp_file.txt", "w");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, "https://upload.wistia.com" );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);    
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback');
curl_setopt($ch, CURLOPT_BUFFERSIZE, (1024*1024*512));
curl_setopt($ch, CURLOPT_NOPROGRESS, FALSE);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$result = curl_exec($ch);
echo $result; 
fwrite($fp, $result);
curl_close($ch);
fclose($fp);

which returns a string

 $result={"id":5966875,"name":"php3il8M4","type":"Video","created":"2014-02-18T10:00:57+00:00","updated":"2014-02-18T10:00:57+00:00","duration":10.29,"hashed_id":"772ecmi61h","description":"","progress":0.0,"status":"queued","thumbnail":{"url":"http://embed.wistia.com/deliveries/a351871a559000f83c39f3e84b33a491c5e5224a.jpg?image_crop_resized=100x60&video_still_time=5","width":100,"height":60}}

I would like to only write to mysql the value after the "name":" eg. php3il8M4

And update my mysql db eg

 UPDATE $table SET code='$name' WHERE id=$id

I'm not sure what is the best way to do this.

1 Answer 1

4

You can use as

$data = json_decode($result,true);
$name = $data["name"];

Here $name will contain the name and you can use it in the query

Sign up to request clarification or add additional context in comments.

3 Comments

cannot believe it.. o_O
you were the first ;)
I would say sensitive mind think alike since GREAT is a very heavy weighted word for me :)

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.